diff options
-rw-r--r-- | youtube/__init__.py | 1 | ||||
-rw-r--r-- | youtube/channel.py | 7 | ||||
-rw-r--r-- | youtube/playlist.py | 3 | ||||
-rw-r--r-- | youtube/templates/base.html | 3 |
4 files changed, 9 insertions, 5 deletions
diff --git a/youtube/__init__.py b/youtube/__init__.py index c2ce276..3c271f1 100644 --- a/youtube/__init__.py +++ b/youtube/__init__.py @@ -5,6 +5,7 @@ import traceback import re from sys import exc_info yt_app = flask.Flask(__name__) +yt_app.config['TEMPLATES_AUTO_RELOAD'] = True yt_app.url_map.strict_slashes = False diff --git a/youtube/channel.py b/youtube/channel.py index ad6db5b..e9cc87b 100644 --- a/youtube/channel.py +++ b/youtube/channel.py @@ -150,7 +150,8 @@ def get_number_of_videos_channel(channel_id): response = response.decode('utf-8') - match = re.search(r'"numVideosText":\s*{\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response) + # match = re.search(r'"numVideosText":\s*{\s*"runs":\s*\[{"text":\s*"([\d,]*) videos"', response) + match = re.search(r'"numVideosText".*?([,\d]+)', response) if match: return int(match.group(1).replace(',','')) else: @@ -209,7 +210,7 @@ def get_channel_page_general_url(base_url, tab, request, channel_id=None): if tab == 'videos' and channel_id: tasks = ( - gevent.spawn(get_number_of_videos_channel, channel_id), + gevent.spawn(get_number_of_videos_channel, channel_id), gevent.spawn(get_channel_tab, channel_id, page_number, sort, 'videos', view) ) gevent.joinall(tasks) @@ -217,7 +218,7 @@ def get_channel_page_general_url(base_url, tab, request, channel_id=None): number_of_videos, polymer_json = tasks[0].value, tasks[1].value elif tab == 'videos': tasks = ( - gevent.spawn(get_number_of_videos_general, base_url), + gevent.spawn(get_number_of_videos_general, base_url), gevent.spawn(util.fetch_url, base_url + '/videos?pbj=1&view=0', headers_desktop, debug_name='gen_channel_videos') ) gevent.joinall(tasks) diff --git a/youtube/playlist.py b/youtube/playlist.py index b7167f6..2e2af98 100644 --- a/youtube/playlist.py +++ b/youtube/playlist.py @@ -1,4 +1,4 @@ -from youtube import util, yt_data_extract, proto +from youtube import util, yt_data_extract, proto, local_playlist from youtube import yt_app import base64 @@ -114,6 +114,7 @@ def get_playlist_page(): video_count = 40 return flask.render_template('playlist.html', + header_playlist_names = local_playlist.get_playlist_names(), video_list = info.get('items', []), num_pages = math.ceil(video_count/20), parameters_dictionary = request.args, diff --git a/youtube/templates/base.html b/youtube/templates/base.html index 4ff83c5..44aef20 100644 --- a/youtube/templates/base.html +++ b/youtube/templates/base.html @@ -19,7 +19,8 @@ <header> <a href="/youtube.com" id="home-link">Home</a> <form id="site-search" action="/youtube.com/search"> - <input type="search" name="query" class="search-box" value="{{ search_box_value }}"> + <input type="search" name="query" class="search-box" value="{{ search_box_value }}" + {{ "autofocus" if request.path == "/" else "" }}> <button type="submit" value="Search" class="search-button">Search</button> <div class="dropdown"> <button class="dropdown-label">Options</button> |