aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2020-12-30 00:04:41 -0500
committerJesús <heckyel@hyperbola.info>2020-12-30 00:04:41 -0500
commit056c3be3f2ab9a19d8b2c38396826aaad9d4081d (patch)
tree248bb34a95fab6377c6205abc12d032934e28025
parent0a9d24b2614a8cd814d2fffc5f254034245f6496 (diff)
downloadyt-local-056c3be3f2ab9a19d8b2c38396826aaad9d4081d.tar.lz
yt-local-056c3be3f2ab9a19d8b2c38396826aaad9d4081d.tar.xz
yt-local-056c3be3f2ab9a19d8b2c38396826aaad9d4081d.zip
strip_non_ascii in comments-author-name
-rw-r--r--youtube/comments.py7
-rw-r--r--youtube/static/watch.css6
-rw-r--r--youtube/util.py6
3 files changed, 16 insertions, 3 deletions
diff --git a/youtube/comments.py b/youtube/comments.py
index fff7cb5..8ab2b2c 100644
--- a/youtube/comments.py
+++ b/youtube/comments.py
@@ -1,5 +1,8 @@
from youtube import proto, util, yt_data_extract
-from youtube.util import concat_or_none
+from youtube.util import (
+ concat_or_none,
+ strip_non_ascii
+)
from youtube import yt_app
import settings
@@ -88,6 +91,7 @@ def single_comment_ctoken(video_id, comment_id):
def post_process_comments_info(comments_info):
for comment in comments_info['comments']:
+ comment['author'] = strip_non_ascii(comment['author'])
comment['author_url'] = concat_or_none(
'/', comment['author_url'])
comment['author_avatar'] = concat_or_none(
@@ -114,7 +118,6 @@ def post_process_comments_info(comments_info):
else:
comment['view_replies_text'] = str(reply_count) + ' replies'
-
if comment['like_count'] == 1:
comment['likes_text'] = '1 like'
else:
diff --git a/youtube/static/watch.css b/youtube/static/watch.css
index e448e39..3f1b7cf 100644
--- a/youtube/static/watch.css
+++ b/youtube/static/watch.css
@@ -520,7 +520,11 @@ label[for=options-toggle-cbox] {
}
.author-avatar { grid-area: author-avatar; }
-.author-name { grid-area: author-name; }
+.author-name {
+ grid-area: author-name;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
.permalink { grid-area: permalink; }
.comment-text {
grid-area: comment-text;
diff --git a/youtube/util.py b/youtube/util.py
index e92fed5..3d5546a 100644
--- a/youtube/util.py
+++ b/youtube/util.py
@@ -601,3 +601,9 @@ def to_valid_filename(name):
name = '_' + name
return name
+
+
+def strip_non_ascii(string):
+ ''' Returns the string without non ASCII characters'''
+ stripped = (c for c in string if 0 < ord(c) < 127)
+ return ''.join(stripped)