Browse Source

Improve search maybe

main
fluffy 6 months ago
parent
commit
fd8b565007
1 changed files with 12 additions and 11 deletions
  1. +12
    -11
      beatbot.py

+ 12
- 11
beatbot.py View File

@@ -13,22 +13,23 @@ def randline(fname):

def bot():
genre = randline('genres.txt')
if genre:
genre += ' '
beats = "lo-fi {}beats to {} and {} to".format(
genre,
randline('1syllableverbs.txt'), randline('2syllableverbs.txt'))
verb1 = randline('1syllableverbs.txt')
verb2 = randline('2syllableverbs.txt')

mdon = mastodon.Mastodon(
access_token='token.secret',
api_base_url='https://botsin.space')
search_term = f'+lofi {genre} +beats {verb1} {verb2}'
text = f"lo-fi {genre} beats to {verb1} and {verb2} to"

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

print(text)

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

if __name__ == '__main__':


Loading…
Cancel
Save