Harmonize id
This commit is contained in:
parent
50f220afb4
commit
8e9086475d
2 changed files with 33 additions and 18 deletions
|
@ -36,12 +36,12 @@ class SVT(Channel):
|
|||
published_parsed: datetime = datetime.now()
|
||||
video_id = str()
|
||||
|
||||
if svt_id == 'feed':
|
||||
if self.m_id == 'feed':
|
||||
feed = feedparser.parse(self.get_feed())
|
||||
entries = feed['entries']
|
||||
for entry in entries:
|
||||
video_id = hash_string(entry['id'])
|
||||
if video_exists(video_id, svt_id):
|
||||
if video_exists(video_id, self.m_id):
|
||||
break
|
||||
for link in entry['links']:
|
||||
if str(link['type']).startswith('image/'):
|
||||
|
@ -56,9 +56,9 @@ class SVT(Channel):
|
|||
datart = element.get('data-rt')
|
||||
|
||||
if datart == 'top-area-play-button':
|
||||
svt_id = href.split('=')[1].split('&')[0]
|
||||
self.m_id = href.split('=')[1].split('&')[0]
|
||||
|
||||
resolved_link = resolve_link(svt_id)
|
||||
resolved_link = self.resolve_link()
|
||||
description = str(entry['description'])
|
||||
published_parsed = entry['published_parsed']
|
||||
title = str(entry['title'])
|
||||
|
@ -68,12 +68,12 @@ class SVT(Channel):
|
|||
item = Item(description, resolved_link, self.m_provider_name,
|
||||
published_parsed, thumbnail, title)
|
||||
self.m_items.append(item)
|
||||
add_video(video_id, svt_id, self.m_provider_name, description,
|
||||
add_video(video_id, self.m_id, self.m_provider_name, description,
|
||||
resolved_link, published_parsed, thumbnail, title, 0)
|
||||
|
||||
else:
|
||||
chan_dict = resolve_svt_channel(svt_id)
|
||||
resolved_link = resolve_link(svt_id)
|
||||
chan_dict = resolve_svt_channel(self.m_id)
|
||||
resolved_link = self.resolve_link()
|
||||
video_id = hash_string(resolved_link)
|
||||
title = chan_dict['name']
|
||||
description = "Live channel stream"
|
||||
|
@ -85,15 +85,15 @@ class SVT(Channel):
|
|||
self.m_items.append(item)
|
||||
|
||||
|
||||
def resolve_link(svt_id: str) -> str:
|
||||
api = json.loads(
|
||||
requests.get('https://api.svt.se/video/{}'.format(svt_id)).text)
|
||||
resolved_link = ''
|
||||
def resolve_link(self) -> str:
|
||||
api = json.loads(
|
||||
requests.get('https://api.svt.se/video/{}'.format(self.m_id)).text)
|
||||
resolved_link = ''
|
||||
|
||||
try:
|
||||
for reference in api['videoReferences']:
|
||||
if reference['format'] == "dashhbbtv":
|
||||
resolved_link = reference['url']
|
||||
except KeyError:
|
||||
pass
|
||||
return resolved_link
|
||||
try:
|
||||
for reference in api['videoReferences']:
|
||||
if reference['format'] == "dashhbbtv":
|
||||
resolved_link = reference['url']
|
||||
except KeyError:
|
||||
pass
|
||||
return resolved_link
|
||||
|
|
|
@ -129,6 +129,21 @@ def get_latest(provider_id: str,
|
|||
pass
|
||||
return videos
|
||||
|
||||
def get_latest_video_timestamp(channel_id: str,
|
||||
basepath: str = BASEPATH,
|
||||
filename: str = DB_FILE_NAME) -> datetime:
|
||||
fullpath = path.join(basepath, filename)
|
||||
try:
|
||||
con = sqlite3.connect(fullpath)
|
||||
cur = con.cursor()
|
||||
select_query = '''SELECT max(published) FROM {} WHERE channel_id = ?'''.format(
|
||||
VIDEO_TABLE)
|
||||
cur.execute(select_query, [channel_id])
|
||||
timestamp = cur.fetchone()[0]
|
||||
except sqlite3.OperationalError:
|
||||
timestamp = 0
|
||||
pass
|
||||
return datetime.fromtimestamp(timestamp)
|
||||
|
||||
def get_subscriptions(basepath: str = BASEPATH,
|
||||
filename: str = DB_FILE_NAME) -> list[tuple[str, str]]:
|
||||
|
|
Loading…
Add table
Reference in a new issue