Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
无聊人士张
you-get
提交
d6af782f
Y
you-get
项目概览
无聊人士张
/
you-get
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
you-get
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d6af782f
编写于
9月 02, 2014
作者:
M
Mort Yao
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jackyzy823-develop' into develop
* iQIYI: fix #334 and close #150 * QQ: fix #381
上级
79455bbc
2545b69f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
118 addition
and
27 deletion
+118
-27
src/you_get/extractors/iqiyi.py
src/you_get/extractors/iqiyi.py
+93
-19
src/you_get/extractors/qq.py
src/you_get/extractors/qq.py
+25
-8
未找到文件。
src/you_get/extractors/iqiyi.py
浏览文件 @
d6af782f
...
@@ -3,8 +3,62 @@
...
@@ -3,8 +3,62 @@
__all__
=
[
'iqiyi_download'
]
__all__
=
[
'iqiyi_download'
]
from
..common
import
*
from
..common
import
*
from
uuid
import
uuid4
from
random
import
random
,
randint
import
json
from
math
import
floor
import
hashlib
'''
com.qiyi.player.core.model.def.DefinitonEnum
bid meaning for quality
0 none
1 standard
2 high
3 super
4 suprt-high
5 fullhd
10 4k
96 topspeed
'''
def
getVRSXORCode
(
arg1
,
arg2
):
loc3
=
arg2
%
3
if
loc3
==
1
:
return
arg1
^
121
if
loc3
==
2
:
return
arg1
^
72
return
arg1
^
103
def
getVrsEncodeCode
(
vlink
):
loc6
=
0
loc2
=
''
loc3
=
vlink
.
split
(
"-"
)
loc4
=
len
(
loc3
)
# loc5=loc4-1
for
i
in
range
(
loc4
-
1
,
-
1
,
-
1
):
loc6
=
getVRSXORCode
(
int
(
loc3
[
loc4
-
i
-
1
],
16
),
i
)
loc2
+=
chr
(
loc6
)
return
loc2
[::
-
1
]
def
getVMS
(
tvid
,
vid
,
uid
):
tm
=
randint
(
1000
,
2000
)
vmsreq
=
'http://cache.video.qiyi.com/vms?key=fvip&src=p'
+
"&tvId="
+
tvid
+
"&vid="
+
vid
+
"&vinfo=1&tm="
+
str
(
tm
)
+
"&enc="
+
hashlib
.
new
(
'md5'
,
bytes
(
'ts56gh'
+
str
(
tm
)
+
tvid
,
"utf-8"
)).
hexdigest
()
+
"&qyid="
+
uid
+
"&tn="
+
str
(
random
())
return
json
.
loads
(
get_content
(
vmsreq
))
def
getDispathKey
(
rid
):
tp
=
")(*&^flash@#$%a"
#magic from swf
time
=
json
.
loads
(
get_content
(
"http://data.video.qiyi.com/t?tn="
+
str
(
random
())))[
"t"
]
t
=
str
(
int
(
floor
(
int
(
time
)
/
(
10
*
60.0
))))
return
hashlib
.
new
(
"md5"
,
bytes
(
t
+
tp
+
rid
,
"utf-8"
)).
hexdigest
()
def
iqiyi_download
(
url
,
output_dir
=
'.'
,
merge
=
True
,
info_only
=
False
):
def
iqiyi_download
(
url
,
output_dir
=
'.'
,
merge
=
True
,
info_only
=
False
):
gen_uid
=
uuid4
().
hex
html
=
get_html
(
url
)
html
=
get_html
(
url
)
tvid
=
r1
(
r
'data-player-tvid="([^"]+)"'
,
html
)
tvid
=
r1
(
r
'data-player-tvid="([^"]+)"'
,
html
)
...
@@ -12,26 +66,46 @@ def iqiyi_download(url, output_dir = '.', merge = True, info_only = False):
...
@@ -12,26 +66,46 @@ def iqiyi_download(url, output_dir = '.', merge = True, info_only = False):
assert
tvid
assert
tvid
assert
videoid
assert
videoid
info_url
=
'http://cache.video.qiyi.com/vj/%s/%s/'
%
(
tvid
,
videoid
)
info
=
getVMS
(
tvid
,
videoid
,
gen_uid
)
info
=
get_html
(
info_url
)
raise
NotImplementedError
(
'iqiyi'
)
title
=
info
[
"data"
][
"vi"
][
"vn"
]
from
xml.dom.minidom
import
parseString
#for highest qualities
doc
=
parseString
(
info_xml
)
#for http://www.iqiyi.com/v_19rrmmz5yw.html not vp -> np
title
=
doc
.
getElementsByTagName
(
'title'
)[
0
].
firstChild
.
nodeValue
try
:
size
=
int
(
doc
.
getElementsByTagName
(
'totalBytes'
)[
0
].
firstChild
.
nodeValue
)
if
not
info
[
"data"
][
"vp"
]
and
info
[
"data"
][
'vp'
][
"tkl"
]
==
''
:
urls
=
[
n
.
firstChild
.
nodeValue
for
n
in
doc
.
getElementsByTagName
(
'file'
)]
raise
ValueError
assert
urls
[
0
].
endswith
(
'.f4v'
),
urls
[
0
]
except
:
log
.
e
(
"[Error] Do not support for iQIYI VIP video."
)
for
i
in
range
(
len
(
urls
)):
exit
(
-
1
)
temp_url
=
"http://data.video.qiyi.com/%s"
%
urls
[
i
].
split
(
"/"
)[
-
1
].
split
(
"."
)[
0
]
+
".ts"
try
:
# assert info["data"]['vp']["tkl"]!=''
response
=
request
.
urlopen
(
temp_url
)
bid
=
0
except
request
.
HTTPError
as
e
:
for
i
in
info
[
"data"
][
"vp"
][
"tkl"
][
0
][
"vs"
]:
key
=
r1
(
r
'key=(.*)'
,
e
.
geturl
())
if
int
(
i
[
"bid"
])
<=
10
and
int
(
i
[
"bid"
])
>=
bid
:
assert
key
bid
=
int
(
i
[
"bid"
])
urls
[
i
]
+=
"?key=%s"
%
key
video_links
=
i
[
"fs"
]
#todo support choose quality with cmdline
urls
=
[]
size
=
0
for
i
in
video_links
:
vlink
=
i
[
"l"
]
# print(vlink)
if
not
vlink
.
startswith
(
"/"
):
#vlink is encode
vlink
=
getVrsEncodeCode
(
vlink
)
assert
vlink
.
endswith
(
".f4v"
)
size
+=
i
[
"b"
]
key
=
getDispathKey
(
vlink
.
split
(
"/"
)[
-
1
].
split
(
"."
)[
0
])
baseurl
=
info
[
"data"
][
"vp"
][
"du"
].
split
(
"/"
)
baseurl
.
insert
(
-
1
,
key
)
url
=
"/"
.
join
(
baseurl
)
+
vlink
+
'?su='
+
gen_uid
+
'&client=&z=&bt=&ct=&tn='
+
str
(
randint
(
10000
,
20000
))
urls
.
append
(
json
.
loads
(
get_content
(
url
))[
"l"
])
#download should be complete in 10 minutes
#because the url is generated before start downloading
#and the key may be expired after 10 minutes
print_info
(
site_info
,
title
,
'flv'
,
size
)
print_info
(
site_info
,
title
,
'flv'
,
size
)
if
not
info_only
:
if
not
info_only
:
download_urls
(
urls
,
title
,
'flv'
,
size
,
output_dir
=
output_dir
,
merge
=
merge
)
download_urls
(
urls
,
title
,
'flv'
,
size
,
output_dir
=
output_dir
,
merge
=
merge
)
...
...
src/you_get/extractors/qq.py
浏览文件 @
d6af782f
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
__all__
=
[
'qq_download'
]
__all__
=
[
'qq_download'
]
from
..common
import
*
from
..common
import
*
import
uuid
#QQMUSIC
#QQMUSIC
#SINGLE
#SINGLE
#1. http://y.qq.com/#type=song&mid=000A9lMb0iEqwN
#1. http://y.qq.com/#type=song&mid=000A9lMb0iEqwN
...
@@ -25,19 +25,36 @@ def qq_download_by_id(id, title=None, output_dir='.', merge=True, info_only=Fals
...
@@ -25,19 +25,36 @@ def qq_download_by_id(id, title=None, output_dir='.', merge=True, info_only=Fals
doc_vl
=
doc_root
.
getElementsByTagName
(
'vl'
)[
0
]
doc_vl
=
doc_root
.
getElementsByTagName
(
'vl'
)[
0
]
doc_vi
=
doc_vl
.
getElementsByTagName
(
'vi'
)[
0
]
doc_vi
=
doc_vl
.
getElementsByTagName
(
'vi'
)[
0
]
fn
=
doc_vi
.
getElementsByTagName
(
'fn'
)[
0
].
firstChild
.
data
fn
=
doc_vi
.
getElementsByTagName
(
'fn'
)[
0
].
firstChild
.
data
fclip
=
doc_vi
.
getElementsByTagName
(
'fclip'
)[
0
].
firstChild
.
data
# fclip = doc_vi.getElementsByTagName('fclip')[0].firstChild.data
if
int
(
fclip
)
>
0
:
# fc=doc_vi.getElementsByTagName('fc')[0].firstChild.data
fn
=
fn
[:
-
4
]
+
"."
+
fclip
+
fn
[
-
4
:]
fvkey
=
doc_vi
.
getElementsByTagName
(
'fvkey'
)[
0
].
firstChild
.
data
fvkey
=
doc_vi
.
getElementsByTagName
(
'fvkey'
)[
0
].
firstChild
.
data
doc_ul
=
doc_vi
.
getElementsByTagName
(
'ul'
)
doc_ul
=
doc_vi
.
getElementsByTagName
(
'ul'
)
url
=
doc_ul
[
0
].
getElementsByTagName
(
'url'
)[
0
].
firstChild
.
data
url
=
url
+
fn
+
'?vkey='
+
fvkey
_
,
ext
,
size
=
url_info
(
url
)
url
=
doc_ul
[
0
].
getElementsByTagName
(
'url'
)[
1
].
firstChild
.
data
# print(i.firstChild.data)
urls
=
[]
ext
=
fn
[
-
3
:]
size
=
0
for
i
in
doc
.
getElementsByTagName
(
"cs"
):
size
+=
int
(
i
.
firstChild
.
data
)
# size=sum(map(int,doc.getElementsByTagName("cs")))
locid
=
str
(
uuid
.
uuid4
())
for
i
in
doc
.
getElementsByTagName
(
"ci"
):
urls
.
append
(
url
+
fn
[:
-
4
]
+
"."
+
i
.
getElementsByTagName
(
"idx"
)[
0
].
firstChild
.
data
+
fn
[
-
4
:]
+
'?vkey='
+
fvkey
+
'&sdtfrom=v1000&type='
+
fn
[
-
3
:
0
]
+
'&locid='
+
locid
+
"&&level=1&platform=11&br=133&fmt=hd&sp=0"
)
print
(
urls
)
# if int(fclip) > 0:
# fn = fn[:-4] + "." + fclip + fn[-4:]
# url = url + fn + '?vkey=' + fvkey
# _, ext, size = url_info(url)
print_info
(
site_info
,
title
,
ext
,
size
)
print_info
(
site_info
,
title
,
ext
,
size
)
if
not
info_only
:
if
not
info_only
:
download_urls
(
[
url
]
,
title
,
ext
,
size
,
output_dir
=
output_dir
,
merge
=
merge
)
download_urls
(
urls
,
title
,
ext
,
size
,
output_dir
=
output_dir
,
merge
=
merge
)
def
qq_download
(
url
,
output_dir
=
'.'
,
merge
=
True
,
info_only
=
False
):
def
qq_download
(
url
,
output_dir
=
'.'
,
merge
=
True
,
info_only
=
False
):
if
re
.
match
(
r
'http://v.qq.com/([^\?]+)\?vid'
,
url
):
if
re
.
match
(
r
'http://v.qq.com/([^\?]+)\?vid'
,
url
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录