Compare commits

..

No commits in common. '090a0af7e699b821458773f6d06bf1e5934e4f01' and 'a2403b56cdc59d350202822e322ed1dda79930b6' have entirely different histories.

@ -16,7 +16,7 @@ from requests import HTTPError
import common
import common.dateutil
from common.database import DBManager, query, get_column_placeholder
from common.media import check_for_media, download_media, WrongContent
from common.media import check_for_media, download_media
from common.sheets import Sheets as SheetsClient
from .sheets import SheetsEventsMiddleware, SheetsPlaylistsMiddleware, SheetsArchiveMiddleware
@ -329,16 +329,13 @@ class EventsSync(SheetSync):
def download_media(self, url):
hostname = urlparse(url).hostname
if hostname in ("youtu.be", "youtube.com", "www.youtube.com"):
if hostname in ("youtu.be", "youtube.com"):
self.logger.info(f"Ignoring url {url!r}: Blocklisted hostname")
if check_for_media(self.media_dir, url):
self.logger.info(f"Already have content for url {url!r}")
return
try:
download_media(url, self.media_dir)
except WrongContent as e:
self.logger.info(f"Ignoring url {url!r}: {e}")
return
except Exception:
self.logger.warning(f"Failed to download url {url!r}", exc_info=True)
raise

@ -76,7 +76,9 @@ def hour_to_shift(hour, start_time):
"""Converts an hour number into a datetime, shift number (0-3), shift name, and hour-of-shift (1-6)"""
start_time = datetime.utcfromtimestamp(start_time)
current_time = (start_time + timedelta(hours=hour)).replace(minute=0, second=0, microsecond=0)
current_time_pst = current_time - timedelta(hours=7) # TODO change this back to 8
utc = ZoneInfo("utc")
pst = ZoneInfo("America/Vancouver")
current_time_pst = current_time.replace(tzinfo=utc).astimezone(pst)
hour_pst = current_time_pst.hour
shift = hour_pst // 6
shift_name = ["zeta", "dawn-guard", "alpha-flight", "night-watch"][shift]

Loading…
Cancel
Save