RobbieClarken / youtube-channel-to-playlist

Add all videos from a YouTube channel to a playlist
MIT License
30 stars 3 forks source link

cannot be added as it is already in the playlist #2

Closed orschiro closed 5 years ago

orschiro commented 5 years ago

Dear @RobbieClarken,

I am trying to get your script to work. However, it raises below error although the playlist is empty:

https://www.youtube.com/playlist?list=PLj5bhjq9U0_adeAmPmQZxGqAR2hzSnZqr&disable_polymer=true

Any ideas?

Yours

[orschiro@x230 youtube-channel-to-playlist]$ channel_to_playlist --secrets client_secrets.json UCeZzpJTrjHgTDCJp0X0Ta8g PLj5bhjq9U0_adeAmPmQZxGqAR2hzSnZqr --allow-duplicates
Traceback (most recent call last):
  File "/usr/bin/channel_to_playlist", line 11, in <module>
    load_entry_point('YouTubeChannelToPlaylist==2.0.0', 'console_scripts', 'channel_to_playlist')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2318, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2324, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/site-packages/channel_to_playlist.py", line 94
    f"video {video_id} cannot be added as it is already in the playlist"
                                                                       ^
SyntaxError: invalid syntax
RobbieClarken commented 5 years ago

Hi @orschiro - the problem looks to be you are using Python 2.7 and the code is only compatible with Python 3.6+ (I will update the readme to specify this). It is usually not too much trouble to install Python 3 alongside Python 2. I personally use pyenv to manage multiple Python versions.

orschiro commented 5 years ago

Thanks @RobbieClarken! Tried the same with pip3. Can you help me with this error now?

[orschiro@x230 youtube-channel-to-playlist]$ channel_to_playlist --secrets client_secrets.json UCeZzpJTrjHgTDCJp0X0Ta8g PLj5bhjq9U0_adeAmPmQZxGqAR2hzSnZqr
Adding video 1 of 1443Traceback (most recent call last):
  File "/usr/local/bin/channel_to_playlist", line 11, in <module>
    load_entry_point('YouTubeChannelToPlaylist==2.0.0', 'console_scripts', 'channel_to_playlist')()
  File "/usr/local/lib/python3.6/site-packages/channel_to_playlist.py", line 127, in main
    add_to_playlist(youtube, args.playlist_id, video_ids, f, args.allow_duplicates)
  File "/usr/local/lib/python3.6/site-packages/channel_to_playlist.py", line 90, in add_to_playlist
    add_video_to_playlist(youtube, playlist_id, video_id)
  File "/usr/local/lib/python3.6/site-packages/channel_to_playlist.py", line 70, in add_video_to_playlist
    "resourceId": {"videoId": video_id, "kind": "youtube#video"},
  File "/usr/local/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/googleapiclient/http.py", line 840, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&alt=json returned "Forbidden">
RobbieClarken commented 5 years ago

I'm not really sure what is going on now. Is the playlist (PLj5bhjq9U0_adeAmPmQZxGqAR2hzSnZqr) created by the same user that was used to generate client_secrets.json? I tested adding videos from channel UCeZzpJTrjHgTDCJp0X0Ta8g to a playlist I created and it worked. Perhaps try with a different different playlist or regenerating the client credentials?

orschiro commented 5 years ago

Dear @RobbieClarken, now it seems to be working.

I redid the entire process and ensured that I was logged in with the same (email) account under Google Developer console and YouTube.

First time I tried it, I was logged into the Developer Console with my Gmail account but with a YouTube Channel (?) account. For the latter, I am manager with my Gmail account. It's a bit of mess with those different accounts that Google / Gmail / YouTube has.

Thanks for all your advice and support! :-)

image