Created
October 6, 2016 22:22
-
-
Save AnthonyBloomer/8b8e62b06349b0cf9a93ef2a60d649d1 to your computer and use it in GitHub Desktop.
This file contains 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
import sys | |
import requests | |
import random | |
import subprocess | |
if len(sys.argv) == 2: | |
genre = sys.argv[1] | |
request = requests.get('https://yts.ag/api/v2/list_movies.json?genre=%s&minimum_rating=8&limit=50' % genre) | |
if request.status_code == 200: | |
result = request.json() | |
if result['status'] == 'ok': | |
random_movie = random.choice(result['data']['movies']) | |
print 'Playing %s!' % random_movie['title'] | |
command = 'peerflix %s --mpv' % random_movie['torrents'][0]['url'] | |
subprocess.Popen(["/bin/bash", "-c", command]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment