Skip to content

Instantly share code, notes, and snippets.

@sanfx
Forked from syndbg/fetch.py
Last active September 18, 2022 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanfx/2552632aaadf8c6bc80d1585f238cc37 to your computer and use it in GitHub Desktop.
Save sanfx/2552632aaadf8c6bc80d1585f238cc37 to your computer and use it in GitHub Desktop.
A small Python script, that fetches a YouTube playlist's videos titles and writes them to a file playlist.txt in the same directory. Usage? A legal backup against video deletion. You could always find the song if you know the song title before it got removed
import gdata.youtube
import gdata.youtube.service
# Dependencies:
# - Python==3.10
# - gdata-python3==2.0.18
# - google-api-python-client==1.2
yt_service = gdata.youtube.service.YouTubeService()
yt_service.ssl = True
playlist_uri = ""
# Can be left blank and be set on input
# playlist_uri = "http://gdata.youtube.com/feeds/api/playlists/F835FEAB20A328D9"
if playlist_uri == "":
playlist_uri = str(input("Playlist URI: "))
playlist_songs = []
playlist_video_feed = yt_service.GetYouTubePlaylistVideoFeed(playlist_uri)
for playlist_video_entry in playlist_video_feed.entry:
playlist_songs.append(playlist_video_entry.title.text)
f = open("playlist.txt", "w")
for entry in playlist_songs:
f.write(entry + "\n");
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment