Ability to post comments (not reply yet)

This commit is contained in:
James Taylor 2018-08-29 00:33:28 -07:00
parent 6a6433619f
commit fee24d4f0a
5 changed files with 104 additions and 87 deletions

View File

@ -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:]:

View File

@ -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;

View File

@ -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,

View File

@ -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'

View File

@ -22,8 +22,93 @@
grid-template-columns: 1fr 640px;
}
.full-item{
grid-column: 2;
display: grid;
grid-column: 2;
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;
}
.comment-count{
font-weight:bold;
grid-row:9;
grid-column: 1 / span 2;
}
.post-comment-link{
grid-row:10;
grid-column: 1;
justify-self:start;
}
.full-item .comments{
grid-column: 1 / span 2;
grid-row: 11;
margin-top:10px;
}
.comment{
width:640px;
}
.full-item .more-comments{
grid-row: 12;
grid-column: 1 / span 2;
}
.music-list{
background-color: #d0d0d0;
}
@ -39,17 +124,6 @@
font-weight:bold;
margin-bottom:5px;
}
.comments{
grid-column: 1 / span 2;
grid-row: 6;
margin-top:10px;
}
.comment{
width:640px;
}
.more-comments{
grid-column: 1 / span 2;
}
#right{
background-color:#cccccc;
grid-column: 2;
@ -129,6 +203,8 @@ $download_options
<div class="music-list">
$music_list
</div>
<div class="comment-count">$comment_count</div>
$post_comment_link
<section class="comments">
$comments
</section>