Browse Source

Minor cleanups

main
fluffy 5 months ago
parent
commit
dca65a083a
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      beatbot.py

+ 8
- 8
beatbot.py View File

@@ -47,25 +47,25 @@ def bot():
except pickle.UnpicklingError:
LOGGER.exception("Seen database corrupted")

video_ids = youtube.get_videos(search_term)
videos = youtube.get_videos(search_term)
LOGGER.info("%s: Found %d videos (%d new)", search_term,
len(video_ids), len(set(video_ids) - seen_vids))
len(videos), len(set(videos) - seen_vids))

yt_id = None

random.shuffle(video_ids)
random.shuffle(videos)

# try to find a random video we haven't used before
for (vid, title) in video_ids:
for (vid, title) in videos:
if vid not in seen_vids:
yt_id = vid
LOGGER.info("Using [https://youtube.com/watch?v=%s] - %s", yt_id, title)
LOGGER.info("Using [https://youtube.com/watch?v=%s] %s", yt_id, title)
break

if not yt_id and video_ids:
if not yt_id and videos:
# nothing new, so just select a random one (list is already shuffled)
(yt_id, title) = video_ids[0]
LOGGER.info("Reusing [https://youtube.com/watch?v=%s] - %s", yt_id, title)
(yt_id, title) = videos[0]
LOGGER.info("Reusing [https://youtube.com/watch?v=%s] %s", yt_id, title)

if yt_id:
text += f'\n\nhttps://youtube.com/watch?v={yt_id}'


Loading…
Cancel
Save