Skip to content

Commit

Permalink
Fixing rss and get_output
Browse files Browse the repository at this point in the history
  • Loading branch information
geirawsm committed Dec 22, 2024
1 parent 27094e2 commit acf6e0e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
19 changes: 11 additions & 8 deletions sausage_bot/cogs/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async def control_posting(feed_type, action):
feed_type_in = []
failed_list = []
feed_type_list = []
feed_types = ''
actions = {
'start': {'status_update': 'started'},
'stop': {'status_update': 'stopped'},
Expand All @@ -112,7 +113,8 @@ async def control_posting(feed_type, action):
feed_type_in.append(feed_type)
for feed_type in feed_type_in:
try:
eval(f'RSSfeed.post_{feed_type}.{action}()')
log.verbose(f'RSSfeed.{feed_type}_posting.{action}()')
eval(f'RSSfeed.{feed_type}_posting.{action}()')
feed_type_list.append(feed_type)
except RuntimeError:
failed_list.append(feed_type)
Expand All @@ -133,8 +135,9 @@ async def control_posting(feed_type, action):
feed_types = ', '.join(feed_type_list)
if len(failed_list) > 0:
failed_list_text = ', '.join(failed_list)
_msg = ''
if len(feed_types) > 0:
_msg = I18N.t(
_msg += I18N.t(
f'rss.commands.{action}.msg_confirm_ok',
feed_type=feed_types
)
Expand Down Expand Up @@ -179,7 +182,7 @@ def __init__(self, bot):
@rss_posting_group.command(
name='start', description=locale_str(I18N.t('rss.commands.start.cmd'))
)
async def rss_posting_start(
async def feeds_posting_start(
self, interaction: discord.Interaction, feed_type: typing.Literal[
'feeds', 'podcasts', 'ALL'
]
Expand All @@ -191,7 +194,7 @@ async def rss_posting_start(
@rss_posting_group.command(
name='stop', description=locale_str(I18N.t('rss.commands.stop.cmd'))
)
async def rss_posting_stop(
async def feeds_posting_stop(
self, interaction: discord.Interaction, feed_type: typing.Literal[
'feeds', 'podcasts', 'ALL'
]
Expand All @@ -205,7 +208,7 @@ async def rss_posting_stop(
'rss.commands.restart.cmd'
))
)
async def rss_posting_restart(
async def feeds_posting_restart(
self, interaction: discord.Interaction, feed_type: typing.Literal[
'feeds', 'podcasts', 'ALL'
]
Expand Down Expand Up @@ -355,21 +358,21 @@ async def rss_edit(
updates_in.append(('feed_name', new_feed_name))
changes_out += '\n- {}: `{}` -> `{}`'.format(
I18N.t('rss.commands.edit.changes_out.feed_name'),
feed_info[0][0],
feed_info[0]['feed_name'],
new_feed_name
)
if channel:
updates_in.append(('channel', channel))
changes_out += '\n- {}: `{}` -> `{}`'.format(
I18N.t('rss.commands.edit.changes_out.channel'),
feed_info[0][1],
feed_info[0]['channel'],
channel
)
if url:
updates_in.append(('url', url))
changes_out += '\n- {}: `{}` -> `{}`'.format(
I18N.t('rss.commands.edit.changes_out.url'),
feed_info[0][2],
feed_info[0]['url'],
url
)
await db_helper.update_fields(
Expand Down
8 changes: 4 additions & 4 deletions sausage_bot/util/db_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ async def add_missing_db_setup(
template_info=template_info,
select=('setting', 'value')
)
db_out_cols = [col['setting'] for col in db_out]
log.verbose(f'Got `inserts`: {inserts}')
log.verbose(f'Got `db_out`: {db_out}')
db_out = dict(db_out)
log.verbose(f'Got `dict(db_out)`: {db_out}')
for insert in inserts:
if insert[0] not in db_out:
if insert[0] not in db_out_cols:
temp_inserts.append(insert)
elif insert[0] in db_out and db_out[insert[0]] is None:
elif insert[0] in db_out and db_out[db_out_cols.index(insert[0])] is None:
temp_inserts.append(insert)
log.debug(f'temp_inserts: {temp_inserts}')
if len(temp_inserts) > 0:
Expand Down
3 changes: 2 additions & 1 deletion sausage_bot/util/feeds_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ async def add_to_feed_db(
async def remove_feed_from_db(feed_type, feed_name):
'Remove a feed from `feed file` based on `feed_name`'
removal_ok = True
if feed_type == 'rss':
if feed_type in ['rss', 'spotify']:
feed_db = envs.rss_db_schema
feed_db_filter = envs.rss_db_filter_schema
elif feed_type == 'youtube':
Expand All @@ -224,6 +224,7 @@ async def remove_feed_from_db(feed_type, feed_name):
where=[('feed_name', feed_name)],
single=True
)
uuid_from_db = uuid_from_db['uuid']
log.debug(f'`uuid_from_db` is {uuid_from_db}')
removal = await db_helper.del_row_by_AND_filter(
feed_db,
Expand Down

0 comments on commit acf6e0e

Please sign in to comment.