Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Use with Kodi, install youtube-dl with (sudo) pip3 install youtube-dl
- # Save as yt.py
- # Add alias yt='python3 yt.py' in .bashrc (Raspberry Pi for example)
- # Use as yt https://www.youtube.com/playlist?list=PL55Jv4fGPIb8zQysIJQGi8Gl7ziO1P8O_
- # Select file.STRM from Kodi or VLC (or something other)
- # Works with .m3u8 files, single songs link, playlist links.
- from re import findall
- import subprocess
- from subprocess import Popen
- from sys import argv
- result = subprocess.Popen(["youtube-dl", "-g", argv[1]], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- output, error = result.communicate()
- output = output.decode('utf-8')
- urls = findall(r'(https?://\S+)', output)
- f = open("file.STRM", "w")
- blocked = 1
- for i, j in enumerate(urls):
- if not ".m3u8" in j:
- if blocked == 1:
- blocked = 0
- pass
- elif blocked == 0:
- f.write(urls[i] + "\n")
- blocked = 1
- else:
- f.write(urls[i] + "\n")
- f.close()
Add Comment
Please, Sign In to add comment