FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
iScript/flvxz_cl.py at master · surperone/iScript · GitHub
surperone
iScript
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
iScript
/
flvxz_cl.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
168 lines (142 loc) · 4.92 KB
Breadcrumbs
iScript
/
flvxz_cl.py
Copy path
File metadata and controls
executable file
·
168 lines (142 loc) · 4.92 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import
re
import
base64
import
requests
import
os
import
sys
import
argparse
import
random
from
HTMLParser
import
HTMLParser
import
select
s
=
'
\x1b
[%d;%dm%s
\x1b
[0m'
# terminual color template
parser
=
HTMLParser
()
############################################################
# wget exit status
wget_es
=
{
0
:
"No problems occurred."
,
2
:
"User interference."
,
1
<<
8
:
"Generic error code."
,
2
<<
8
:
"Parse error - for instance, when parsing command-line optio.wgetrc or .netrc..."
,
3
<<
8
:
"File I/O error."
,
4
<<
8
:
"Network failure."
,
5
<<
8
:
"SSL verification failure."
,
6
<<
8
:
"Username/password authentication failure."
,
7
<<
8
:
"Protocol errors."
,
8
<<
8
:
"Server issued an error response."
}
############################################################
headers
=
{
"Host"
:
"www.flvxz.com"
,
"User-Agent"
:
"Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 "
\
+
"(KHTML, like Gecko) Chrome/32.0.1700.77 Safari/537.36"
,
"Accept"
:
"*/*"
,
"Accept-Language"
:
"en-US,en;q=0.5"
,
"Accept-Encoding"
:
"gzip, deflate"
,
"Referer"
:
"http://flvxz.com"
,
"Connection"
:
"keep-alive"
}
ss
=
requests
.
session
()
ss
.
headers
.
update
(
headers
)
api
=
'https://www.flvxz.com/getFlv.php?url=%s'
def
download
(
infos
):
if
not
os
.
path
.
exists
(
infos
[
'dir_'
]):
os
.
mkdir
(
infos
[
'dir_'
])
#else:
#if os.path.exists(infos['filename']):
#return 0
num
=
random
.
randint
(
0
,
7
)
%
7
col
=
s
%
(
2
,
num
+
90
,
os
.
path
.
basename
(
infos
[
'filename'
]))
print
'
\n
++ 正在下载:'
,
'#'
,
s
%
(
1
,
97
,
infos
[
'n'
]),
'/'
,
s
%
(
1
,
97
,
infos
[
'amount'
]),
'#'
,
col
cmd
=
'wget -c -nv --user-agent "%s" -O "%s" "%s"'
\
%
(
headers
[
'User-Agent'
],
infos
[
'filename'
],
parser
.
unescape
(
infos
[
'durl'
]))
status
=
os
.
system
(
cmd
)
if
status
!=
0
:
# other http-errors, such as 302.
wget_exit_status_info
=
wget_es
[
status
]
print
(
'
\n
\n
----###
\x1b
[1;91mERROR
\x1b
[0m ==>
\x1b
[1;91m%d (%s)
\x1b
[0m ###---
\n
\n
'
%
(
status
,
wget_exit_status_info
))
print
s
%
(
1
,
91
,
' ===> '
),
cmd
sys
.
exit
(
1
)
def
play
(
infos
):
num
=
random
.
randint
(
0
,
7
)
%
7
col
=
s
%
(
2
,
num
+
90
,
os
.
path
.
basename
(
infos
[
'filename'
]))
print
'
\n
++ play:'
,
'#'
,
s
%
(
1
,
97
,
infos
[
'n'
]),
'/'
,
s
%
(
1
,
97
,
infos
[
'amount'
]),
'#'
,
col
cmd
=
'mpv --really-quiet --cache 8140 --cache-default 8140 '
\
'--http-header-fields "User-Agent:%s" '
\
'"%s"'
%
(
headers
[
'User-Agent'
],
infos
[
'durl'
])
#'"%s"' % parser.unescape(infos['durl'])
status
=
os
.
system
(
cmd
)
timeout
=
1
ii
,
_
,
_
=
select
.
select
([
sys
.
stdin
], [], [],
timeout
)
if
ii
:
sys
.
exit
(
0
)
else
:
pass
def
flvxz_parser
(
cn
):
qualities
=
re
.
findall
(
r'"quality">\[(.+?)\]<'
,
cn
)
if
not
qualities
:
return
{}
j
=
{}
chucks
=
re
.
split
(
r'"quality">\[.+?\]<'
,
cn
)[
1
:]
for
i
in
xrange
(
len
(
qualities
)):
parts
=
re
.
findall
(
r'data-clipboard-text="(.+?)"'
,
chucks
[
i
])
t
=
re
.
findall
(
r'rel="noreferrer" href="(.+?)"'
,
chucks
[
i
])
urls
=
[
ii
for
ii
in
t
if
'flvxz'
not
in
ii
]
j
[
qualities
[
i
]]
=
zip
(
parts
,
urls
)
return
j
def
pickup
(
j
):
print
s
%
(
1
,
97
,
' ++ pick a quality:'
)
qualities
=
j
.
keys
()
qualities
.
sort
()
for
i
in
xrange
(
len
(
qualities
)):
print
s
%
(
1
,
91
,
' %s'
%
(
i
+
1
)),
qualities
[
i
]
p
=
raw_input
(
s
%
(
1
,
92
,
' Enter: '
))
if
p
.
isdigit
():
p
=
int
(
p
)
if
p
<=
len
(
j
):
print
s
%
(
2
,
92
,
' -- %s'
%
qualities
[
p
-
1
])
return
j
[
qualities
[
p
-
1
]]
else
:
print
s
%
(
1
,
91
,
' !! enter error'
)
sys
.
exit
()
else
:
print
s
%
(
1
,
91
,
' !! enter error'
)
sys
.
exit
()
def
main
(
url
):
encode_url
=
base64
.
urlsafe_b64encode
(
url
.
replace
(
'://'
,
':##'
))
url
=
api
%
encode_url
cn
=
ss
.
get
(
url
).
content
j
=
flvxz_parser
(
cn
)
if
j
:
j
=
pickup
(
j
)
else
:
print
s
%
(
1
,
91
,
' !! Can
\'
t get videos'
)
sys
.
exit
()
title
=
re
.
search
(
r'media-heading">(.+?)</'
,
cn
)
title
=
title
.
group
(
1
)
if
title
else
''
yes
=
True
if
len
(
j
)
>
1
else
False
dir_
=
os
.
path
.
join
(
os
.
getcwd
(),
title
)
if
yes
else
os
.
getcwd
()
n
=
args
.
from_
amount
=
len
(
j
)
j
=
j
[
args
.
from_
-
1
:]
for
i
in
j
:
infos
=
{
'filename'
:
os
.
path
.
join
(
dir_
,
i
[
0
]),
'durl'
:
i
[
1
],
'dir_'
:
dir_
,
'amount'
:
amount
,
'n'
:
n
}
if
args
.
play
:
play
(
infos
)
else
:
download
(
infos
)
n
+=
1
if
__name__
==
'__main__'
:
p
=
argparse
.
ArgumentParser
(
description
=
'flvxz'
)
p
.
add_argument
(
'url'
,
help
=
'site url'
)
p
.
add_argument
(
'-p'
,
'--play'
,
action
=
'store_true'
, \
help
=
'play with mpv'
)
p
.
add_argument
(
'-f'
,
'--from_'
,
action
=
'store'
, \
default
=
1
,
type
=
int
, \
help
=
'从第几个开始下载,eg: -f 42'
)
args
=
p
.
parse_args
()
main
(
args
.
url
)
Back
|
FazBrowse Home
|
New Git URL