mirror of
https://github.com/Findus23/RadioStats.git
synced 2024-09-19 16:03:48 +02:00
remove debug and add fix
This commit is contained in:
parent
8ee97ea5ce
commit
e992fa7197
4 changed files with 7 additions and 7 deletions
2
fetch.py
2
fetch.py
|
@ -42,8 +42,6 @@ def add_entry(time, artist, title):
|
|||
|
||||
|
||||
for channel in Channel.select():
|
||||
if channel.shortname != "kht":
|
||||
continue
|
||||
if channel.has_data:
|
||||
if channel.shortname == "kht":
|
||||
pars = kronehit
|
||||
|
|
|
@ -7,7 +7,5 @@ def get(channel):
|
|||
for track in fetch(URL, True)["items"]:
|
||||
artist = track["ArtistName"]
|
||||
title = track["TrackName"]
|
||||
print(track["PlayTime"])
|
||||
time = time_to_date(string_to_time(track["PlayTime"]))
|
||||
print(string_to_time(track["PlayTime"]))
|
||||
yield time, artist, title
|
||||
|
|
|
@ -8,7 +8,7 @@ itsdangerous==0.24
|
|||
Jinja2==2.10
|
||||
MarkupSafe==1.0
|
||||
mysqlclient==1.3.12
|
||||
peewee==3.0.18
|
||||
peewee==3.1.0
|
||||
pytz==2018.3
|
||||
requests==2.18.4
|
||||
spotipy==2.4.4
|
||||
|
|
8
utils.py
8
utils.py
|
@ -1,6 +1,7 @@
|
|||
from datetime import datetime, timedelta
|
||||
from time import sleep
|
||||
|
||||
import pytz
|
||||
import requests
|
||||
|
||||
headers = {
|
||||
|
@ -36,7 +37,7 @@ def string_to_time(timestring):
|
|||
|
||||
:rtype: datetime.time
|
||||
"""
|
||||
return datetime.strptime(timestring, "%H:%M:%S").utcnow().time()
|
||||
return datetime.strptime(timestring, "%H:%M:%S").time()
|
||||
|
||||
|
||||
def time_to_date(time):
|
||||
|
@ -52,7 +53,10 @@ def time_to_date(time):
|
|||
if 0 <= current_hour <= 3 and 22 <= time_hour <= 24:
|
||||
day = datetime.today() - timedelta(days=1)
|
||||
|
||||
return datetime.combine(day.date(), time)
|
||||
local = datetime.combine(day.date(), time)
|
||||
tz = pytz.timezone("Europe/Vienna")
|
||||
local_dt = tz.localize(local)
|
||||
return local_dt.astimezone(pytz.utc)
|
||||
|
||||
|
||||
def fetch(url, json=False):
|
||||
|
|
Loading…
Reference in a new issue