aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-07-08 01:06:54 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-07-08 01:06:54 -0700
commit6ad09eb53a8b79b2241f56009d9757f8cac7181f (patch)
treebbdad0456c1dc202fe8c93e9f1a521c8db06fec3 /youtube
parentf36c1d26a40a31cbf1de9cbdb8451f84c4eb01c6 (diff)
downloadyt-local-6ad09eb53a8b79b2241f56009d9757f8cac7181f.tar.lz
yt-local-6ad09eb53a8b79b2241f56009d9757f8cac7181f.tar.xz
yt-local-6ad09eb53a8b79b2241f56009d9757f8cac7181f.zip
server-side support for adding to local playlists
Diffstat (limited to 'youtube')
-rw-r--r--youtube/local_playlist.py13
-rw-r--r--youtube/watch_later.py11
-rw-r--r--youtube/youtube.py6
3 files changed, 16 insertions, 14 deletions
diff --git a/youtube/local_playlist.py b/youtube/local_playlist.py
new file mode 100644
index 0000000..057555a
--- /dev/null
+++ b/youtube/local_playlist.py
@@ -0,0 +1,13 @@
+import os.path
+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:
+ for info in video_info_list:
+ file.write(info + "\n")
+
+
+def get_playlist_page(name):
+ pass \ No newline at end of file
diff --git a/youtube/watch_later.py b/youtube/watch_later.py
deleted file mode 100644
index 4bb421c..0000000
--- a/youtube/watch_later.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import os.path
-import json
-watch_later_file = os.path.normpath("youtube/watch_later.txt")
-def add_to_watch_later(video_info_list):
- with open(watch_later_file, "a", encoding='utf-8') as file:
- for info in video_info_list:
- file.write(info + "\n")
-
-
-def get_watch_later_page():
- pass \ No newline at end of file
diff --git a/youtube/youtube.py b/youtube/youtube.py
index a7cc204..01e956a 100644
--- a/youtube/youtube.py
+++ b/youtube/youtube.py
@@ -1,6 +1,6 @@
import mimetypes
import urllib.parse
-from youtube import watch_later, watch, search, playlist, channel, comments
+from youtube import local_playlist, watch, search, playlist, channel, comments
YOUTUBE_FILES = (
"/shared.css",
"/opensearch.xml",
@@ -47,8 +47,8 @@ def youtube(env, start_response):
elif method == "POST":
if path == "/edit_playlist":
fields = urllib.parse.parse_qs(env['wsgi.input'].read().decode())
- if fields['action'][0] == 'add' and fields['playlist_name'][0] == 'watch_later':
- watch_later.add_to_watch_later(fields['video_info_list'])
+ if fields['action'][0] == 'add':
+ local_playlist.add_to_playlist(fields['playlist_name'][0], fields['video_info_list'])
start_response('204 No Content', ())
else: