Last active
August 28, 2017 08:09
-
-
Save Felhamed/ac12834915e3599dad8577d7b229394e to your computer and use it in GitHub Desktop.
Generate mpv playlist from url directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import sys | |
| import requests | |
| import subprocess | |
| from bs4 import BeautifulSoup | |
| url = sys.argv[1] | |
| response = requests.get(url) | |
| soup = BeautifulSoup(response.content, "html.parser") | |
| preurl='http://vid.archive' | |
| file = open("playlist.txt", "w") | |
| for a in soup.find_all('a', href=True): | |
| file.write(a['href']+'\n') | |
| file.close() | |
| with open('playlist.txt', 'r') as fin: | |
| data = fin.read().splitlines(True) | |
| data = [preurl + s for s in data] | |
| with open('playlist.txt', 'w') as fout: | |
| fout.writelines(data[1:]) | |
| subprocess.run(["mpv", "--playlist=playlist.txt"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment