-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfc2dl.py
executable file
·48 lines (36 loc) · 1.31 KB
/
fc2dl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import os, sys, re, commands, argparse, hashlib, requests
FC2magick = '_gGddgPfeaf_gzyr' #updated FC2 2011.7
""" argments setting
"""
parser = argparse.ArgumentParser(description='FC2 video download script.')
parser.add_argument('target_url',
help='fc2 video page url.')
parser.add_argument('-o', '-O', '--outfile',
help='output filename.')
args = parser.parse_args()
match = re.search(r'http:\/\/video\.fc2\.com\/content\/(\w+)/?$', args.target_url)
print args
if match is None:
match = re.search(r'http:\/\/video\.fc2\.com\/a\/content\/(\w+)/?$', args.target_url)
if match is None:
print "doesn't match"
quit()
target = match.group(1)
print 'target:', target
mini = hashlib.md5(target + FC2magick).hexdigest()
ginfo_url = 'http://video.fc2.com/ginfo.php?mimi=' + mini + '&v=' + target + '&upid=' + target + '&otag=1'
#print ginfo_url
filepath = commands.getoutput("curl -L -R '%s'" % ginfo_url)
#print filepath
title = filepath.split('&')[15].split('=')[1] # title(need encode)
url = filepath.split('&')[0].split('=')[1] + '?' + filepath.split('&')[1]
print title
print 'flv url:', url
print args.outfile
if args.outfile:
title = args.outfile
command = "curl -L -R -o '%s.flv' '%s'" % (title, url)
print command
os.system(command)