Move published_string to a property of the Video object.

master
voussoir 2021-03-24 20:29:15 -07:00
parent b134a8783b
commit cfad775a0a
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
3 changed files with 10 additions and 8 deletions

View File

@ -1,4 +1,3 @@
import datetime
import flask; from flask import request
import itertools
import traceback
@ -57,12 +56,6 @@ def get_channel(channel_id=None, state=None):
videos = list(videos)
for video in videos:
published = video.published
published = datetime.datetime.utcfromtimestamp(published)
published = published.strftime('%Y %m %d')
video._published_str = published
all_states = common.ycdldb.get_all_states()
return flask.render_template(

View File

@ -208,7 +208,7 @@ https://stackoverflow.com/a/35153397
>
<img class="video_thumbnail" loading="lazy" src="http://i3.ytimg.com/vi/{{video.id}}/default.jpg" height="100px">
<div class="video_details">
<a class="video_title" href="https://www.youtube.com/watch?v={{video.id}}">{{video._published_str}} - {{video.title}}</a>
<a class="video_title" href="https://www.youtube.com/watch?v={{video.id}}">{{video.published_string}} - {{video.title}}</a>
<span>({{video.duration | seconds_to_hms}})</span>
<span>({{video.views}})</span>
{% if channel is none %}

View File

@ -1,3 +1,5 @@
import datetime
from . import constants
from . import exceptions
from . import ytrss
@ -221,3 +223,10 @@ class Video(Base):
if commit:
self.ycdldb.commit()
@property
def published_string(self):
published = self.published
published = datetime.datetime.utcfromtimestamp(published)
published = published.strftime('%Y-%m-%d')
return published