Create media__tasks.py

+ `wait_for_premiere`
This commit is contained in:
tcely 2025-05-16 06:50:03 -04:00 committed by GitHub
parent 7287bc1dee
commit 9de2728f35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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,)