diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-08-29 00:33:28 -0700 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-08-29 00:33:28 -0700 |
commit | fee24d4f0a3ddcf877facfa9b22d470bee37ee79 (patch) | |
tree | 6c2084feca5596ec2bc239bbdca2d35c6066364b /youtube | |
parent | 6a6433619f82652d7943e29579fe6cf1bbf0cc11 (diff) | |
download | yt-local-fee24d4f0a3ddcf877facfa9b22d470bee37ee79.tar.lz yt-local-fee24d4f0a3ddcf877facfa9b22d470bee37ee79.tar.xz yt-local-fee24d4f0a3ddcf877facfa9b22d470bee37ee79.zip |
Ability to post comments (not reply yet)
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/common.py | 3 | ||||
-rw-r--r-- | youtube/shared.css | 72 | ||||
-rw-r--r-- | youtube/watch.py | 7 | ||||
-rw-r--r-- | youtube/youtube.py | 9 |
4 files changed, 16 insertions, 75 deletions
diff --git a/youtube/common.py b/youtube/common.py index 384d560..f867ea9 100644 --- a/youtube/common.py +++ b/youtube/common.py @@ -169,7 +169,8 @@ def fetch_url(url, headers=(), timeout=15, report_text=None): content = gzip.decompress(content) return content -mobile_ua = (('User-Agent', 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1'),) +mobile_user_agent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1' +mobile_ua = (('User-Agent', mobile_user_agent),) def dict_add(*dicts): for dictionary in dicts[1:]: diff --git a/youtube/shared.css b/youtube/shared.css index cc640b4..712a2fe 100644 --- a/youtube/shared.css +++ b/youtube/shared.css @@ -176,78 +176,6 @@ address{ - -.full-item{ - display: grid; - grid-template-rows: 0fr 0fr 0fr 0fr 20px 0fr 0fr; - grid-template-columns: 1fr 1fr; - align-content: start; -} - .full-item video{ - grid-column: 1 / span 2; - grid-row: 1; - } - .full-item .title{ - grid-column: 1 / span 2; - grid-row:2; - min-width: 0; - } - .full-item .is-unlisted{ - background-color: #d0d0d0; - justify-self:start; - padding-left:2px; - padding-right:2px; - } - .full-item>address{ - grid-column: 1; - grid-row: 4; - justify-self: start; - } - .full-item .views{ - grid-column: 2; - grid-row: 4; - justify-self:end; - } - .full-item time{ - grid-column: 1; - grid-row: 5; - justify-self:start; - } - .full-item .likes-dislikes{ - grid-column: 2; - grid-row: 5; - justify-self:end; - } - .full-item .download-dropdown{ - grid-column:1; - grid-row: 6; - } - .full-item .checkbox{ - justify-self:end; - - grid-row: 6; - grid-column: 2; - } - .full-item .description{ - background-color:#d0d0d0; - margin-top:8px; - white-space: pre-wrap; - min-width: 0; - - grid-column: 1 / span 2; - grid-row: 7; - } - .full-item .music-list{ - grid-row:8; - grid-column: 1 / span 2; - } - .full-item .comments{ - grid-row: 9; - } - .full-item .more-comments{ - grid-row: 10; - } - .medium-item-box{ display:grid; diff --git a/youtube/watch.py b/youtube/watch.py index d98cd3f..ad3c448 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -385,7 +385,6 @@ def get_watch_page(query_string): music_list_html += '''</tr>\n''' music_list_html += '''</table>\n''' - download_options = '' for format in info['formats']: @@ -396,6 +395,10 @@ def get_watch_page(query_string): note = html.escape(downloader._format_note(format)), ) + post_comment_url = common.URL_ORIGIN + "/post_comment?v=" + id + post_comment_link = '''<a class="post-comment-link" href="''' + post_comment_url + '''">Post comment</a>''' + + page = yt_watch_template.substitute( video_title = html.escape(info["title"]), page_title = html.escape(info["title"]), @@ -411,6 +414,8 @@ def get_watch_page(query_string): description = html.escape(info["description"]), video_sources = formats_html(sorted_formats) + subtitles_html(info), related = related_videos_html, + post_comment_link = post_comment_link, + comment_count = '', comments = comments_html, more_comments_button = more_comments_button, music_list = music_list_html, diff --git a/youtube/youtube.py b/youtube/youtube.py index 446de0d..3c31fa4 100644 --- a/youtube/youtube.py +++ b/youtube/youtube.py @@ -1,6 +1,6 @@ import mimetypes import urllib.parse -from youtube import local_playlist, watch, search, playlist, channel, comments, common +from youtube import local_playlist, watch, search, playlist, channel, comments, common, account_functions YOUTUBE_FILES = ( "/shared.css", "/opensearch.xml", @@ -52,6 +52,9 @@ def youtube(env, start_response): result = common.fetch_url('https://www.youtube.com' + path + ('?' + query_string if query_string else '')) result = result.replace(b"align:start position:0%", b"") return result + elif path == "/post_comment": + start_response('200 OK', () ) + return account_functions.get_post_comment_page(query_string).encode() else: start_response('404 Not Found', () ) return b'404 Not Found' @@ -77,6 +80,10 @@ def youtube(env, start_response): else: start_response('400 Bad Request', ()) return b'400 Bad Request' + elif path == "/post_comment": + start_response('200 OK', () ) + return account_functions.post_comment(query_string, fields).encode() + else: start_response('404 Not Found', ()) return b'404 Not Found' |