mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-23 05:26:37 +00:00
Create media__tasks.py
+ `wait_for_premiere`
This commit is contained in:
parent
7287bc1dee
commit
9de2728f35
22
tubesync/sync/models/media__tasks.py
Normal file
22
tubesync/sync/models/media__tasks.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
|
||||||
|
def wait_for_premiere(self):
|
||||||
|
hours = lambda td: 1+int((24*td.days)+(td.seconds/(60*60)))
|
||||||
|
|
||||||
|
in_hours = None
|
||||||
|
if self.has_metadata or not self.published:
|
||||||
|
return (False, in_hours,)
|
||||||
|
|
||||||
|
now = timezone.now()
|
||||||
|
if self.published < now:
|
||||||
|
in_hours = 0
|
||||||
|
self.manual_skip = False
|
||||||
|
self.skip = False
|
||||||
|
else:
|
||||||
|
in_hours = hours(self.published - now)
|
||||||
|
self.manual_skip = True
|
||||||
|
self.title = _(f'Premieres in {in_hours} hours')
|
||||||
|
|
||||||
|
return (True, in_hours,)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user