Remove redundant _iter_playlist, just use get_playlist_videos.
This commit is contained in:
parent
f2e8aeb568
commit
3ff5de67bc
1 changed files with 2 additions and 4 deletions
|
@ -71,7 +71,7 @@ class Youtube:
|
||||||
user = self.youtube.channels().list(part='snippet', id=uid).execute()
|
user = self.youtube.channels().list(part='snippet', id=uid).execute()
|
||||||
return user['items'][0]['snippet']['title']
|
return user['items'][0]['snippet']['title']
|
||||||
|
|
||||||
def _iter_playlist(self, playlist_id):
|
def get_playlist_videos(self, playlist_id):
|
||||||
page_token = None
|
page_token = None
|
||||||
while True:
|
while True:
|
||||||
response = self.youtube.playlistItems().list(
|
response = self.youtube.playlistItems().list(
|
||||||
|
@ -93,8 +93,6 @@ class Youtube:
|
||||||
if page_token is None:
|
if page_token is None:
|
||||||
break
|
break
|
||||||
|
|
||||||
def get_playlist_videos(self, playlist_id):
|
|
||||||
yield from self._iter_playlist(playlist_id)
|
|
||||||
|
|
||||||
def get_user_videos(self, username=None, uid=None):
|
def get_user_videos(self, username=None, uid=None):
|
||||||
if username:
|
if username:
|
||||||
|
@ -102,7 +100,7 @@ class Youtube:
|
||||||
else:
|
else:
|
||||||
user = self.youtube.channels().list(part='contentDetails', id=uid).execute()
|
user = self.youtube.channels().list(part='contentDetails', id=uid).execute()
|
||||||
upload_playlist_id = user['items'][0]['contentDetails']['relatedPlaylists']['uploads']
|
upload_playlist_id = user['items'][0]['contentDetails']['relatedPlaylists']['uploads']
|
||||||
yield from self._iter_playlist(upload_playlist_id)
|
yield from self.get_playlist_videos(upload_playlist_id)
|
||||||
|
|
||||||
def get_related_videos(self, video_id, count=50):
|
def get_related_videos(self, video_id, count=50):
|
||||||
if isinstance(video_id, Video):
|
if isinstance(video_id, Video):
|
||||||
|
|
Loading…
Reference in a new issue