Repository: pytube/pytube

Issue:
Get all links from channel
Hi,

How to get the links to all videos from channel?

It is advisable not to edit the package code (if possible).

I looked at the 2020 solutions, but the package code has already changed. A new solution is required. 

Discussion:

Patch:
diff --git a/pytube/__main__.py b/pytube/__main__.py
index 0aab151..f619015 100644
--- a/pytube/__main__.py
+++ b/pytube/__main__.py
@@ -268,6 +268,8 @@ class YouTube:
             elif status == 'ERROR':
                 if reason == 'Video unavailable':
                     raise exceptions.VideoUnavailable(video_id=self.video_id)
+            elif status == 'LIVE_STREAM':
+                raise exceptions.LiveStreamError(video_id=self.video_id)
 
     @property
     def vid_info(self):
diff --git a/pytube/contrib/channel.py b/pytube/contrib/channel.py
index 083dcea..73d0720 100644
--- a/pytube/contrib/channel.py
+++ b/pytube/contrib/channel.py
@@ -14,10 +14,10 @@ class Channel(Playlist):
     def __init__(self, url: str, proxies: Optional[Dict[str, str]] = None):
         super().__init__(url, proxies)
 
-        self.channel_name = extract.channel_name(url)
+        self.channel_uri = extract.channel_name(url)
 
         self.channel_url = (
-            f"https://www.youtube.com/c/{self.channel_name}"
+            f"https://www.youtube.com{self.channel_uri}"
         )
         self.videos_url = self.channel_url + '/videos'
         self.playlists_url = self.channel_url + '/playlists'
diff --git a/pytube/extract.py b/pytube/extract.py
index 64f4a25..a26b03e 100644
--- a/pytube/extract.py
+++ b/pytube/extract.py
@@ -134,6 +134,8 @@ def playability_status(watch_html: str) -> (str, str):
     """
     player_response = initial_player_response(watch_html)
     status_dict = player_response.get('playabilityStatus', {})
+    if 'liveStreamability' in status_dict:
+        return 'LIVE_STREAM', 'Video is a live stream.'
     if 'status' in status_dict:
         if 'reason' in status_dict:
             return status_dict['status'], [status_dict['reason']]
@@ -193,16 +195,17 @@ def channel_name(url: str) -> str:
         YouTube channel name.
     """
     patterns = [
-        r"(?:\/c\/([\d\w_\-]+)(\/.*)?)",
-        r"(?:\/channel\/([\w\d_\-]+)(\/.*)?)"
+        r"(?:\/(c)\/([\d\w_\-]+)(\/.*)?)",
+        r"(?:\/(channel)\/([\w\d_\-]+)(\/.*)?)"
     ]
     for pattern in patterns:
         regex = re.compile(pattern)
         function_match = regex.search(url)
         if function_match:
             logger.debug("finished regex search, matched: %s", pattern)
-            channel_id = function_match.group(1)
-            return channel_id
+            uri_style = function_match.group(1)
+            uri_identifier = function_match.group(2)
+            return f'/{uri_style}/{uri_identifier}'
 
     raise RegexMatchError(
         caller="channel_name", pattern="patterns"


Test patch:
diff --git a/tests/contrib/test_channel.py b/tests/contrib/test_channel.py
index 5a2b25e..adf6a43 100644
--- a/tests/contrib/test_channel.py
+++ b/tests/contrib/test_channel.py
@@ -20,7 +20,7 @@ def test_channel_name(request_get, channel_videos_html):
     request_get.return_value = channel_videos_html
 
     c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos')
-    assert c.channel_name == 'ProgrammingKnowledge'
+    assert c.channel_uri == '/c/ProgrammingKnowledge'
 
 
 @mock.patch('pytube.request.get')