Download videos via flvcd.com
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 python3.2 | |
# by Jakukyo Friel <weakish@gmail.com> under GPL v2 | |
# Download videos via flvcd.com | |
# Usage: flvcd url | |
# TODO: | |
# - Some sites divide video into clips, we need to support it. | |
# - flvcd.com may use '...' in the link address displayed. This script fails under this condition. | |
# Credits | |
# malic's flvpython http://malic.yo2.cn/articles/flvpython.html | |
import urllib.parse | |
import urllib.request | |
import sys | |
import re | |
from subprocess import Popen | |
# CONFIG | |
USER_AGENT = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3' | |
# ENDCONFIG | |
def PARSE_URL(url): | |
"""Parse url for the real video address. | |
url -> (title, actual_url) | |
""" | |
para = {'flag' : '', 'format' : '', 'kw' : url} | |
flvcd = 'http://www.flvcd.com/parse.php?' | |
req = flvcd + urllib.parse.urlencode(para) | |
opener = urllib.request.build_opener() | |
opener.addheaders = [('User-agent', USER_AGENT)] | |
data = opener.open(req).read().decode('gb2312') | |
title = re.search('document\.title = "([^"]*)"', data).group(1) | |
link = re.search('>(http://[^<]*)</a>',data).group(1) | |
return title, link | |
def FETCH_VIDEO(pair): | |
"""Download videos.""" | |
title, link = pair | |
Popen(['wget','-c', link, '-U', USER_AGENT, | |
'-O', title + '.flv']).wait() | |
def main(): | |
FETCH_VIDEO(PARSE_URL(sys.argv[1])) | |
if __name__ == "__main__": | |
main() |
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 rc | |
endnum = $1 | |
playlistid = $2 | |
seq 1 $endnum | xargs -I '{}' flvcd http://www.letv.com/ptv/pplay/$playlistid/'{}'.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment