Skip to content

Instantly share code, notes, and snippets.

@AnthonyBloomer
Created October 6, 2016 22:22
Show Gist options
  • Save AnthonyBloomer/8b8e62b06349b0cf9a93ef2a60d649d1 to your computer and use it in GitHub Desktop.
Save AnthonyBloomer/8b8e62b06349b0cf9a93ef2a60d649d1 to your computer and use it in GitHub Desktop.
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