Skip to content
Snippets Groups Projects
Commit ae7b0382 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

Fixed #4 - wrong channel name

parent 2d613d3e
Branches
Tags
No related merge requests found
......@@ -105,10 +105,11 @@ class SaveMyPlaylist:
for item in response['items']:
snippet = item['snippet']
title = snippet['title']
channel = snippet['channelTitle']
videoId = snippet['resourceId']['videoId']
items.append((channel, title, videoId))
logger.info('{} - {} (videoId: {})'.format(channel, title, videoId))
channelName = self.__get_channel_name(videoId)
items.append((channelName, title, videoId))
logger.info(f'{channelName} - {title} (videoId: {videoId})')
nextPageToken = None
if 'nextPageToken' in response:
......@@ -116,6 +117,19 @@ class SaveMyPlaylist:
return items, nextPageToken
def __get_channel_name(self, videoId):
request = self._youtubeApi.videos().list(
part='snippet',
id=videoId,
maxResults=1
)
response = request.execute()
if not response['items']:
return ''
return response['items'][0]['snippet']['channelTitle']
def download_items(self, destinationFolder, debug=False):
os.makedirs(destinationFolder, exist_ok=True)
logger.info('>>> Scanning destination folder...')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment