Browse Source

Choose any video

main
fluffy 6 months ago
parent
commit
1cdec66d8a
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      beatbot.py

+ 3
- 4
beatbot.py View File

@@ -18,16 +18,15 @@ def bot():
beats = "lo-fi {}beats to {} and {} to".format(
genre,
randline('1syllableverbs.txt'), randline('2syllableverbs.txt'))
print(beats)

mdon = mastodon.Mastodon(
access_token='token.secret',
api_base_url='https://botsin.space')

query = requests.get(f'https://www.youtube.com/results?search_query={beats}')
match = re.search(r'\?v=([^"]+)"', query.text)
if match:
beats += f'\n\nhttps://youtube.com/watch?v={match.group(1)}'
vids = re.findall(r'watch\?v=([^"]{11})"', query.text)
if vids:
beats += f'\n\nhttps://youtube.com/watch?v={random.choice(vids)}'

print(beats)
mdon.status_post(beats)


Loading…
Cancel
Save