diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-07-08 02:56:54 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-07-08 16:22:23 -0700 |
commit | 26620cbac85f1fa5057e54fa8d91c35d907c0e0f (patch) | |
tree | 40763f1590f80c1d4e5d7d0ac1c1ce9d720ad3fb /youtube/local_playlist.py | |
parent | 6ad09eb53a8b79b2241f56009d9757f8cac7181f (diff) | |
download | yt-local-26620cbac85f1fa5057e54fa8d91c35d907c0e0f.tar.lz yt-local-26620cbac85f1fa5057e54fa8d91c35d907c0e0f.tar.xz yt-local-26620cbac85f1fa5057e54fa8d91c35d907c0e0f.zip |
front-end support for adding to playlists
Diffstat (limited to 'youtube/local_playlist.py')
-rw-r--r-- | youtube/local_playlist.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/youtube/local_playlist.py b/youtube/local_playlist.py index 057555a..5a4182b 100644 --- a/youtube/local_playlist.py +++ b/youtube/local_playlist.py @@ -1,13 +1,19 @@ -import os.path +import os import json playlists_directory = os.path.normpath("data/playlists") def add_to_playlist(name, video_info_list): - with open(os.path.join(playlists_directory, name), "a", encoding='utf-8') as file: + with open(os.path.join(playlists_directory, name + ".txt"), "a", encoding='utf-8') as file: for info in video_info_list: file.write(info + "\n") def get_playlist_page(name): - pass
\ No newline at end of file + pass + +def get_playlist_names(): + for item in os.listdir(playlists_directory): + name, ext = os.path.splitext(item) + if ext == '.txt': + yield name
\ No newline at end of file |