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()
|
published_parsed: datetime = datetime.now()
|
||||||
video_id = str()
|
video_id = str()
|
||||||
|
|
||||||
if svt_id == 'feed':
|
if self.m_id == 'feed':
|
||||||
feed = feedparser.parse(self.get_feed())
|
feed = feedparser.parse(self.get_feed())
|
||||||
entries = feed['entries']
|
entries = feed['entries']
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
video_id = hash_string(entry['id'])
|
video_id = hash_string(entry['id'])
|
||||||
if video_exists(video_id, svt_id):
|
if video_exists(video_id, self.m_id):
|
||||||
break
|
break
|
||||||
for link in entry['links']:
|
for link in entry['links']:
|
||||||
if str(link['type']).startswith('image/'):
|
if str(link['type']).startswith('image/'):
|
||||||
|
@ -56,9 +56,9 @@ class SVT(Channel):
|
||||||
datart = element.get('data-rt')
|
datart = element.get('data-rt')
|
||||||
|
|
||||||
if datart == 'top-area-play-button':
|
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'])
|
description = str(entry['description'])
|
||||||
published_parsed = entry['published_parsed']
|
published_parsed = entry['published_parsed']
|
||||||
title = str(entry['title'])
|
title = str(entry['title'])
|
||||||
|
@ -68,12 +68,12 @@ class SVT(Channel):
|
||||||
item = Item(description, resolved_link, self.m_provider_name,
|
item = Item(description, resolved_link, self.m_provider_name,
|
||||||
published_parsed, thumbnail, title)
|
published_parsed, thumbnail, title)
|
||||||
self.m_items.append(item)
|
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)
|
resolved_link, published_parsed, thumbnail, title, 0)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
chan_dict = resolve_svt_channel(svt_id)
|
chan_dict = resolve_svt_channel(self.m_id)
|
||||||
resolved_link = resolve_link(svt_id)
|
resolved_link = self.resolve_link()
|
||||||
video_id = hash_string(resolved_link)
|
video_id = hash_string(resolved_link)
|
||||||
title = chan_dict['name']
|
title = chan_dict['name']
|
||||||
description = "Live channel stream"
|
description = "Live channel stream"
|
||||||
|
@ -85,9 +85,9 @@ class SVT(Channel):
|
||||||
self.m_items.append(item)
|
self.m_items.append(item)
|
||||||
|
|
||||||
|
|
||||||
def resolve_link(svt_id: str) -> str:
|
def resolve_link(self) -> str:
|
||||||
api = json.loads(
|
api = json.loads(
|
||||||
requests.get('https://api.svt.se/video/{}'.format(svt_id)).text)
|
requests.get('https://api.svt.se/video/{}'.format(self.m_id)).text)
|
||||||
resolved_link = ''
|
resolved_link = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -129,6 +129,21 @@ def get_latest(provider_id: str,
|
||||||
pass
|
pass
|
||||||
return videos
|
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,
|
def get_subscriptions(basepath: str = BASEPATH,
|
||||||
filename: str = DB_FILE_NAME) -> list[tuple[str, str]]:
|
filename: str = DB_FILE_NAME) -> list[tuple[str, str]]:
|
||||||
|
|
Loading…
Add table
Reference in a new issue