diff --git a/server.py b/server.py
index bf85a35..4b39b5a 100644
--- a/server.py
+++ b/server.py
@@ -6,7 +6,7 @@ from youtube import yt_app
from youtube import util
# these are just so the files get run - they import yt_app and add routes to it
-from youtube import watch, search, playlist, channel, local_playlist, comments, post_comment
+from youtube import watch, search, playlist, channel, local_playlist, comments, post_comment, subscriptions
import settings
diff --git a/youtube/subscriptions.py b/youtube/subscriptions.py
index fdba114..a238ae4 100644
--- a/youtube/subscriptions.py
+++ b/youtube/subscriptions.py
@@ -1,21 +1,18 @@
-from youtube import util, yt_data_extract, html_common, channel
+from youtube import util, yt_data_extract, channel
+from youtube import yt_app
import settings
-from string import Template
+
import sqlite3
import os
import time
import gevent
-import html
import json
import traceback
import contextlib
import defusedxml.ElementTree
-with open('yt_subscriptions_template.html', 'r', encoding='utf-8') as f:
- subscriptions_template = Template(f.read())
-
-with open('yt_subscription_manager_template.html', 'r', encoding='utf-8') as f:
- subscription_manager_template = Template(f.read())
+import flask
+from flask import request
thumbnails_directory = os.path.join(settings.data_dir, "subscription_thumbnails")
@@ -272,16 +269,15 @@ def _get_upstream_videos(channel_id):
videos = []
- json_channel_videos = channel.get_grid_items(channel.get_channel_tab(channel_id)[1]['response'])
- for i, json_video in enumerate(json_channel_videos):
- info = yt_data_extract.renderer_info(json_video['gridVideoRenderer'])
- if 'description' not in info:
- info['description'] = ''
+ channel_videos = channel.extract_info(json.loads(channel.get_channel_tab(channel_id)), 'videos')['items']
+ for i, video_item in enumerate(channel_videos):
+ if 'description' not in video_item:
+ video_item['description'] = ''
try:
- info['time_published'] = youtube_timestamp_to_posix(info['published']) - i # subtract a few seconds off the videos so they will be in the right order
+ video_item['time_published'] = youtube_timestamp_to_posix(video_item['published']) - i # subtract a few seconds off the videos so they will be in the right order
except KeyError:
- print(info)
- videos.append((channel_id, info['id'], info['title'], info['duration'], info['time_published'], info['description']))
+ print(video_item)
+ videos.append((channel_id, video_item['id'], video_item['title'], video_item['duration'], video_item['time_published'], video_item['description']))
now = time.time()
download_thumbnails_if_necessary(video[1] for video in videos if (now - video[4]) < 30*24*3600) # Don't download thumbnails from videos older than a month
@@ -380,7 +376,7 @@ def import_subscriptions(env, start_response):
-sub_list_item_template = Template('''
+"""sub_list_item_template = Template('''
-''')
+''')"""
def get_subscription_manager_page(env, start_response):
with open_database() as connection:
with connection as cursor:
@@ -473,8 +469,8 @@ def list_from_comma_separated_tags(string):
return [tag.strip() for tag in string.split(',') if tag.strip()]
-unsubscribe_list_item_template = Template('''
-