mute rss update errors
This commit is contained in:
parent
cf773069f2
commit
579665b6aa
3 changed files with 16 additions and 11 deletions
|
@ -107,8 +107,8 @@ class AbstractSite:
|
||||||
data = ResourceContent()
|
data = ResourceContent()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def scrape_additional_data(self):
|
def scrape_additional_data(self) -> bool:
|
||||||
pass
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def query_str(content, query: str) -> str:
|
def query_str(content, query: str) -> str:
|
||||||
|
|
|
@ -26,8 +26,11 @@ class PodcastUpdater(BaseJob):
|
||||||
logger.info(f"updating {p}")
|
logger.info(f"updating {p}")
|
||||||
c = p.episodes.count()
|
c = p.episodes.count()
|
||||||
site = RSS(p.feed_url)
|
site = RSS(p.feed_url)
|
||||||
site.scrape_additional_data()
|
r = site.scrape_additional_data()
|
||||||
c2 = p.episodes.count()
|
if r:
|
||||||
logger.info(f"updated {p}, {c2 - c} new episodes.")
|
c2 = p.episodes.count()
|
||||||
count += c2 - c
|
logger.info(f"updated {p}, {c2 - c} new episodes.")
|
||||||
|
count += c2 - c
|
||||||
|
else:
|
||||||
|
logger.warning(f"failed to update {p}")
|
||||||
logger.info(f"Podcasts update finished, {count} new episodes total.")
|
logger.info(f"Podcasts update finished, {count} new episodes total.")
|
||||||
|
|
|
@ -111,13 +111,14 @@ class RSS(AbstractSite):
|
||||||
return pd
|
return pd
|
||||||
|
|
||||||
def scrape_additional_data(self):
|
def scrape_additional_data(self):
|
||||||
item = self.get_item()
|
|
||||||
if not item:
|
|
||||||
logger.error(f"item for RSS {self.url} not found")
|
|
||||||
return
|
|
||||||
feed = self.parse_feed_from_url(self.url)
|
feed = self.parse_feed_from_url(self.url)
|
||||||
if not feed:
|
if not feed:
|
||||||
return
|
logger.warning(f"unable to parse RSS {self.url}")
|
||||||
|
return False
|
||||||
|
item = self.get_item()
|
||||||
|
if not item:
|
||||||
|
logger.warning(f"item for RSS {self.url} not found")
|
||||||
|
return False
|
||||||
for episode in feed["episodes"]:
|
for episode in feed["episodes"]:
|
||||||
PodcastEpisode.objects.get_or_create(
|
PodcastEpisode.objects.get_or_create(
|
||||||
program=item,
|
program=item,
|
||||||
|
@ -139,3 +140,4 @@ class RSS(AbstractSite):
|
||||||
"link": episode.get("link"),
|
"link": episode.get("link"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
return True
|
||||||
|
|
Loading…
Add table
Reference in a new issue