Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Oct 26, 2024
1 parent f40532c commit 72d2678
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
10 changes: 9 additions & 1 deletion sausage_bot/locale/rss.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ en:
rss: Administer RSS-feeds
filter: Manage RSS filters
posting: Posting from RSS feeds
settings: Change settings for RSS feeds
commands:
start:
cmd: Start posting
Expand Down Expand Up @@ -63,4 +64,11 @@ en:
normal: Normal
added: Added
filter: Filter
msg_error: No feeds added
msg_error: No feeds added
setting:
cmd: Change a setting for this cog
desc:
name_of_setting: Name of the setting to change
value_in: Value to change the setting to
value_in_input_invalid: 'Invalid input for `value_in`: %{error}'
msg_confirm: Setting updated
10 changes: 9 additions & 1 deletion sausage_bot/locale/rss.no.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ no:
rss: Administrer RSS-feeder
filter: Administrer RSS filters
posting: Posting fra RSS feeds
settings: Endre innstillinger for RSS feeds
commands:
start:
cmd: Start posting
Expand Down Expand Up @@ -63,4 +64,11 @@ no:
normal: Normal
added: Lagt til
filter: Filter
msg_error: Ingen feeds lagt til
msg_error: Ingen feeds lagt til
setting:
cmd: Endre en innstilling for denne cogen
desc:
name_of_setting: Navn på innstilling som skal endres
value_in: Verdi som skal settes
value_in_input_invalid: 'Ugyldig inndata for `value_in`: %{error}'
msg_confirm: Innstilling oppdatert
8 changes: 7 additions & 1 deletion sausage_bot/util/net_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ async def get_link(url):


async def check_spotify_podcast(url):
log.verbose('Checking podcast...')
if _spotipy is None:
_spotipy_error = 'Spotipy has no credentials. Check README'
log.error(_spotipy_error)
await discord_commands.log_to_bot_channel(_spotipy_error)
return None
pod_id = re.search(r'.*/show/([a-zA-Z0-9]+).*', url).group(1)
try:
log.verbose(f'Looking up show id ({pod_id})...')
_show = _spotipy.show(pod_id)
log.debug('`_show`: ', pretty=_show)
return _show
Expand All @@ -85,17 +87,20 @@ async def get_spotify_podcast_links(feed):
UUID = feed[0]
URL = feed[2]
pod_id = re.search(r'.*/show/([a-zA-Z0-9]+).*', URL).group(1)
log.verbose('Getting show info...')
_show = _spotipy.show(pod_id)
log.verbose('Getting DB filters')
filters_db = await db_helper.get_output(
template_info=envs.rss_db_filter_schema,
select=('allow_or_deny', 'filter'),
where=[('uuid', UUID)]
)
log.verbose('Getting DB log')
log_db = await db_helper.get_output(
template_info=envs.rss_db_log_schema,
where=[('uuid', UUID)]
)
episodes = _show['episodes']['items']
episodes = _show['episodes']['items'][0]
items_out = {
'filters': filters_db,
'items': [],
Expand All @@ -113,6 +118,7 @@ async def get_spotify_podcast_links(feed):
'duration': '',
'type': 'spotify',
}
log.verbose('Processing episodes')
for ep in episodes:
temp_info = items_info.copy()
temp_info['title'] = ep['name']
Expand Down

0 comments on commit 72d2678

Please sign in to comment.