This commit is contained in:
pluja 2020-10-16 13:17:58 +02:00
parent 3846264dd4
commit 4b153cf7e9
2 changed files with 39 additions and 7 deletions

View File

@ -80,6 +80,15 @@ def twitter(page=0):
avatarPath = "img/avatars/1.png" avatarPath = "img/avatars/1.png"
posts = [] posts = []
nitter_feed_link = config['nitterInstance']
c = len(followingList)
for user in followingList:
if c != 0:
nitter_feed_link = nitter_feed_link+"{},".format(user.username)
c = c-1
else:
nitter_feed_link = nitter_feed_link+user.username
cache_file = glob.glob("app/cache/{}_*".format(current_user.username)) cache_file = glob.glob("app/cache/{}_*".format(current_user.username))
if (len(cache_file) > 0): if (len(cache_file) > 0):
time_diff = round(time.time() - os.path.getmtime(cache_file[0])) time_diff = round(time.time() - os.path.getmtime(cache_file[0]))
@ -133,7 +142,7 @@ def twitter(page=0):
profilePic = posts[0]['profilePic'] profilePic = posts[0]['profilePic']
return render_template('twitter.html', title='Yotter | Twitter', posts=posts, avatar=avatarPath, return render_template('twitter.html', title='Yotter | Twitter', posts=posts, avatar=avatarPath,
profilePic=profilePic, followedCount=followCount, form=form, config=config, profilePic=profilePic, followedCount=followCount, form=form, config=config,
pages=total_pages, init_page=init_page, actual_page=page) pages=total_pages, init_page=init_page, actual_page=page, nitter_link=nitter_feed_link)
@app.route('/savePost/<url>', methods=['POST']) @app.route('/savePost/<url>', methods=['POST'])
@ -489,7 +498,6 @@ def watch():
except AttributeError or TypeError: except AttributeError or TypeError:
print(info['description']) print(info['description'])
# Get comments # Get comments
videocomments = comments.video_comments(id, sort=0, offset=0, lc='', secret_key='') videocomments = comments.video_comments(id, sort=0, offset=0, lc='', secret_key='')
videocomments = utils.post_process_comments_info(videocomments) videocomments = utils.post_process_comments_info(videocomments)
@ -497,7 +505,10 @@ def watch():
videocomments.sort(key=lambda x: x['likes'], reverse=True) videocomments.sort(key=lambda x: x['likes'], reverse=True)
# Calculate rating % # Calculate rating %
if info['like_count']+info['dislike_count']>0:
info['rating'] = str((info['like_count'] / (info['like_count'] + info['dislike_count'])) * 100)[0:4] info['rating'] = str((info['like_count'] / (info['like_count'] + info['dislike_count'])) * 100)[0:4]
else:
info['rating'] = 50.0
return render_template("video.html", info=info, title='{}'.format(info['title']), config=config, return render_template("video.html", info=info, title='{}'.format(info['title']), config=config,
videocomments=videocomments, vsources=vsources) videocomments=videocomments, vsources=vsources)

View File

@ -56,17 +56,38 @@
<div class="ui horizontal segments"> <div class="ui horizontal segments">
<div class="center aligned ui segment"> <div class="center aligned ui segment">
<a href="{{ url_for('channel', id=info.author_id)}}"> <a href="{{ url_for('channel', id=info.author_id)}}">
<i class="user icon"></i> {{info.author}} <i class="user icon"></i> <b>{{info.author}}</b>
</a> </a>
</div> </div>
<div class="center aligned ui segment"> <div class="center aligned ui segment">
<h4 class="ui header"><i class="grey eye icon"></i>{{info.view_count}}</h4> <div class="ui mini statistic">
<div class="value">
<i class="grey eye icon"></i> <b>{{info.view_count}}</b>
</div>
<div class="label">
views
</div>
</div>
</div> </div>
<div class="center aligned ui segment"> <div class="center aligned ui segment">
{% if info.rating | int > 49 %} {% if info.rating | int > 49 %}
<h4 class="ui header"><i class="green thumbs up icon"></i> {{info.rating}}%</h4> <div class="ui mini statistic">
<div class="value">
<i class="green thumbs up icon"></i> <b>{{info.rating}}%</b>
</div>
<div class="label">
Total: {{info.like_count+info.dislike_count}} votes
</div>
</div>
{% else %} {% else %}
<h4 class="ui header"><i class="red thumbs down icon"></i> {{info.rating}}%</h4> <div class="ui mini statistic">
<div class="value">
<i class="red thumbs down icon"></i> <b>{{info.rating}}%</b>
</div>
<div class="label">
Total: {{info.like_count+info.dislike_count}} votes
</div>
</div>
{% endif %} {% endif %}
</div> </div>
</div> </div>