Skip to content

Commit a1518e7

Browse files
authored
Improve Channel object support for user channels
* Adds support for additional channel URL patterns
1 parent be07012 commit a1518e7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pytube/extract.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def channel_name(url: str) -> str:
187187
188188
- :samp:`https://youtube.com/c/{channel_name}/*`
189189
- :samp:`https://youtube.com/channel/{channel_id}/*
190+
- :samp:`https://youtube.com/u/{channel_name}/*`
191+
- :samp:`https://youtube.com/user/{channel_id}/*
190192
191193
:param str url:
192194
A YouTube url containing a channel name.
@@ -196,7 +198,9 @@ def channel_name(url: str) -> str:
196198
"""
197199
patterns = [
198200
r"(?:\/(c)\/([\d\w_\-]+)(\/.*)?)",
199-
r"(?:\/(channel)\/([\w\d_\-]+)(\/.*)?)"
201+
r"(?:\/(channel)\/([\w\d_\-]+)(\/.*)?)",
202+
r"(?:\/(u)\/([\d\w_\-]+)(\/.*)?)",
203+
r"(?:\/(user)\/([\w\d_\-]+)(\/.*)?)"
200204
]
201205
for pattern in patterns:
202206
regex = re.compile(pattern)

0 commit comments

Comments
 (0)