Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- os.system('pip install twitch-listener')
- os.system('pip install mutagen')
- os.system('pip install ffmpeg')
- os.system('pip install youtube-dl')
- from twitch_listener import listener
- from mutagen.mp3 import MP3
- import ffmpeg
- import time
- file = open('<your twitch username>.log','r+')
- file.truncate(0)
- file.close()
- counter = 1
- bot = listener.connect_twitch('<your twitch username>',
- '<your twitch oauth code>',
- 'o9lf8le4qyj1ckjmj8pd0pya1z6psc')
- channels_to_listen_to = ['<your twitch username>']
- while 1 == 1:
- bot.listen(channels_to_listen_to, duration = 1)
- file = open("<your twitch username>.log","r")
- filetext = file.read()
- playtest = filetext.count("-play ") > 0
- if playtest == True:
- watchindex = int(filetext.find("watch?v=")) + 8
- watchcodeEnd = int(watchindex + 11)
- youtubeurl = "youtube.com/watch?v=" + filetext[watchindex:watchcodeEnd]
- os.system('youtube-dl -f mp4 --output C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp4 "' + youtubeurl + '"')
- os.system('ffmpeg -i "C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp4" C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp3"')
- os.system('del C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp4"')
- audio = MP3('C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp3')
- audiolength = int(audio.info.length)
- os.system('C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp3"')
- time.sleep(audiolength + 5)
- os.system('del C:\\Users\\<your profile name>\\musicfile' + str(counter) + '.mp3"')
- os.system('taskkill /im Music.UI.exe /T /F')
- file.close()
- file = open('jacobacon215.log','r+')
- file.truncate(0)
- file.close()
- counter = counter + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement