Created
April 2, 2013 16:43
-
-
Save scturtle/5293801 to your computer and use it in GitHub Desktop.
play youku with MPlayerX.app
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
#!/usr/bin/env python | |
import re | |
import os | |
import sys | |
import urllib | |
if len(sys.argv) <= 1: | |
print 'Usage: {} [video | videourl]'.format(sys.argv[0]) | |
sys.exit() | |
url = sys.argv[1] | |
if not url.startswith('http://'): | |
url = 'http://v.youku.com/v_show/id_{}.html'.format(url) | |
url = ('http://www.flvcd.com/parse.php?format=super&kw=' + | |
urllib.quote_plus(url)) | |
html = urllib.urlopen(url).read().decode('gbk') | |
links = re.search(r'<input type="hidden" name="inf" value="([^"]+)"', | |
html).groups()[0].strip().split('\r\n') | |
for i, link in enumerate(links): | |
if raw_input('play part {} [y/n]? '.format(i+1)) == 'y': | |
os.system('open -a /Applications/MPlayerX.app --args -url ' + link) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have wrote an enhanced version which automatically quit MPlayerX when next clip plays, I want to make a pull request, but gist does not really support it. Please update it if you feel necessary.