Skip to content

Commit

Permalink
Improve playlist update (get_playlists instead of search)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Apr 26, 2020
1 parent b3581d0 commit 280d85f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions YouTube.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,12 @@ def add_songs(self, playlist, tracks):
f.close()

def get_playlist_id(self, name):
result = {}
pl = self.api.get_playlists()
try:
result = self.api.search(name, 'playlists')[0]
except Exception as e:
print(e)

return result['browseId'][2:]
playlist = next(x for x in pl if x['title'].find(name) != -1)['playlistId']
return playlist
except:
raise Exception("Playlist title not found in playlists")

def remove_songs(self, playlistId):
items = self.api.get_playlist_items(playlistId)
Expand Down

0 comments on commit 280d85f

Please sign in to comment.