Move published_string to a property of the Video object.
This commit is contained in:
parent
b134a8783b
commit
cfad775a0a
3 changed files with 10 additions and 8 deletions
|
@ -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(
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue