aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/local_playlist.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-07-20 01:41:12 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-07-20 01:41:12 -0700
commitd170a75a93e7d722345e328235d62e41cbcd6ae0 (patch)
tree242ad2e26677a9bcd6640f9f9b2dd68b8d2ab9ab /youtube/local_playlist.py
parentf12157cd0203d61bd5ee4f6142562da17f3109a7 (diff)
downloadyt-local-d170a75a93e7d722345e328235d62e41cbcd6ae0.tar.lz
yt-local-d170a75a93e7d722345e328235d62e41cbcd6ae0.tar.xz
yt-local-d170a75a93e7d722345e328235d62e41cbcd6ae0.zip
ability to remove videos from playlist
Diffstat (limited to 'youtube/local_playlist.py')
-rw-r--r--youtube/local_playlist.py34
1 files changed, 11 insertions, 23 deletions
diff --git a/youtube/local_playlist.py b/youtube/local_playlist.py
index 926c93f..5da3b4d 100644
--- a/youtube/local_playlist.py
+++ b/youtube/local_playlist.py
@@ -40,30 +40,18 @@ def get_playlist_names():
if ext == '.txt':
yield name
-'''
- main{
- display:grid;
- grid-template-columns: 3fr 1fr;
- }
-
- header{
- grid-template-columns: 3fr 1fr;
- }
-
- #left{
- grid-column: 1;
- grid-row: 1;
-
- display: grid;
- grid-template-columns: 1fr 800px;
- grid-template-rows: 0fr 1fr 0fr;
- }
+def remove_from_playlist(name, video_info_list):
+ ids = [json.loads(video)['id'] for video in video_info_list]
+ with open(os.path.join(playlists_directory, name + ".txt"), 'r', encoding='utf-8') as file:
+ videos = file.read()
+ videos_in = videos.splitlines()
+ videos_out = []
+ for video in videos_in:
+ if json.loads(video)['id'] not in ids:
+ videos_out.append(video)
+ with open(os.path.join(playlists_directory, name + ".txt"), 'w', encoding='utf-8') as file:
+ file.write("\n".join(videos_out) + "\n")
- #right{
- grid-column: 2;
- grid-row: 1;
- }
-'''
def get_playlists_list_page():
page = '''<ul>\n'''
list_item_template = Template(''' <li><a href="$url">$name</a></li>\n''')