Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
download
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
download
Commits
d4d77b95
Commit
d4d77b95
authored
Apr 28, 2020
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
threading.Lock
parent
f6938618
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
1 deletion
+28
-1
download.py
download.py
+28
-1
No files found.
download.py
View file @
d4d77b95
...
@@ -11,10 +11,18 @@ import threading
...
@@ -11,10 +11,18 @@ import threading
class
DownFile
:
class
DownFile
:
def
__init__
(
self
,
url
,
save_path
=
"./"
,
call_date_string
=
"call_date"
,
page_string
=
"page_no"
):
def
__init__
(
self
,
url
,
save_path
=
"./"
,
call_date_string
=
"call_date"
,
page_string
=
"page_no"
):
"""
初始化
:param url: 下载链接
:param save_path: 保存路径
:param call_date_string: 日期参数
:param page_string: 页码参数
"""
self
.
url
=
url
self
.
url
=
url
self
.
save_path
=
save_path
self
.
save_path
=
save_path
self
.
page_string
=
page_string
self
.
page_string
=
page_string
self
.
call_date_string
=
call_date_string
self
.
call_date_string
=
call_date_string
self
.
lock
=
threading
.
Lock
()
@staticmethod
@staticmethod
def
ali_yun_sdk
(
call_time
,
call_id
):
def
ali_yun_sdk
(
call_time
,
call_id
):
...
@@ -64,7 +72,8 @@ class DownFile:
...
@@ -64,7 +72,8 @@ class DownFile:
def
download_aliyun
(
self
,
data
):
def
download_aliyun
(
self
,
data
):
"""
"""
下载录音
下载阿里云录音
:param data:
:return:
:return:
"""
"""
url
=
local_file
=
""
url
=
local_file
=
""
...
@@ -80,7 +89,9 @@ class DownFile:
...
@@ -80,7 +89,9 @@ class DownFile:
if
len
(
item
[
'voice_file'
])
>
0
:
if
len
(
item
[
'voice_file'
])
>
0
:
local_file
=
self
.
save_path
+
item
[
'voice_file'
]
local_file
=
self
.
save_path
+
item
[
'voice_file'
]
if
self
.
check_file
(
local_file
):
if
self
.
check_file
(
local_file
):
self
.
lock
.
acquire
()
old_num
=
old_num
+
1
old_num
=
old_num
+
1
self
.
lock
.
release
()
continue
continue
time_array
=
time
.
strptime
(
item
[
'call_time'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
time_array
=
time
.
strptime
(
item
[
'call_time'
],
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
...
@@ -126,17 +137,28 @@ class DownFile:
...
@@ -126,17 +137,28 @@ class DownFile:
continue
continue
if
self
.
check_file
(
local_file
):
if
self
.
check_file
(
local_file
):
self
.
lock
.
acquire
()
old_num
=
old_num
+
1
old_num
=
old_num
+
1
self
.
lock
.
release
()
continue
continue
self
.
check_dir
(
self
.
save_path
+
local_dir
)
self
.
check_dir
(
self
.
save_path
+
local_dir
)
result
=
request
.
urlretrieve
(
url
,
local_file
)
result
=
request
.
urlretrieve
(
url
,
local_file
)
self
.
lock
.
acquire
()
download_num
=
download_num
+
1
download_num
=
download_num
+
1
self
.
lock
.
release
()
self
.
log
(
'download_file'
,
result
)
self
.
log
(
'download_file'
,
result
)
self
.
log
(
"download_num"
,
download_num
)
self
.
log
(
"download_num"
,
download_num
)
self
.
log
(
"old_num"
,
old_num
)
self
.
log
(
"old_num"
,
old_num
)
def
download_remote
(
self
,
data
):
def
download_remote
(
self
,
data
):
"""
下载录音服务器录音
:param data:
:return:
"""
num
=
0
num
=
0
old_num
=
0
old_num
=
0
for
item
in
data
:
for
item
in
data
:
...
@@ -182,6 +204,11 @@ class DownFile:
...
@@ -182,6 +204,11 @@ class DownFile:
return
result
return
result
def
start
(
self
):
def
start
(
self
):
"""
开始下载
:return:
"""
page_no
=
1
page_no
=
1
while
True
:
while
True
:
url
=
self
.
url
+
"&"
+
self
.
page_string
+
"="
+
str
(
page_no
)
url
=
self
.
url
+
"&"
+
self
.
page_string
+
"="
+
str
(
page_no
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment