Skip to content

Instantly share code, notes, and snippets.

@jProvim
Forked from scturtle/youku.py
Last active December 27, 2015 05:49
Show Gist options
  • Select an option

  • Save jProvim/7276531 to your computer and use it in GitHub Desktop.

Select an option

Save jProvim/7276531 to your computer and use it in GitHub Desktop.
Updated automatically close the previous MPlayerX when next clip plays.
#!/usr/bin/env python
import re
import os
import sys
import urllib
import time
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("|");
# Remove the last useless clip, since its empty
links.pop();
print "There're total ", len(links), " of clips"
for i, link in enumerate(links):
if raw_input('play part {} [y/n]? '.format(i+1)) == 'y':
killMplayerx = "kill -9 $(ps -ef | grep 'MPlayerX'| awk 'FNR ==1 {print $2}')"
os.system(killMplayerx)
time.sleep(2)
cmd = 'open -a /Applications/MPlayerX.app --args -url ' + link
os.system(cmd)
print "End of Program"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment