Commit 120092d6 authored by hujun's avatar hujun

兼容容联云下载

parent 525e1618
...@@ -65,7 +65,7 @@ class DownFile: ...@@ -65,7 +65,7 @@ class DownFile:
下载录音 下载录音
:return: :return:
""" """
url = "" url = local_file = ""
download_num = 0 download_num = 0
old_num = 0 old_num = 0
count_sleep = 0 count_sleep = 0
...@@ -83,6 +83,11 @@ class DownFile: ...@@ -83,6 +83,11 @@ class DownFile:
if self.check_file(local_file): if self.check_file(local_file):
old_num = old_num + 1 old_num = old_num + 1
continue continue
time_array = time.strptime(item['call_time'], '%Y-%m-%d %H:%M:%S')
local_dir = time.strftime('%Y%m%d', time_array)
if item['type'] == 1:
try: try:
count_sleep = count_sleep + 1 # 增加暂停计数 count_sleep = count_sleep + 1 # 增加暂停计数
url = self.ali_yun_sdk(item['call_time'], item['call_id']) url = self.ali_yun_sdk(item['call_time'], item['call_id'])
...@@ -102,17 +107,24 @@ class DownFile: ...@@ -102,17 +107,24 @@ class DownFile:
"two exception error-----call_time=" + item['call_time'] + '&call_id=' + item['call_id'], "two exception error-----call_time=" + item['call_time'] + '&call_id=' + item['call_id'],
str(result)) str(result))
if url == '': if len(url) == 0:
continue continue
#当数据库未有记录 # 当数据库未有记录
if item['voice_file'] == '': if item['voice_file'] == '':
string_end = url.find("?") string_end = url.find("?")
file_url = url[0:string_end] file_url = url[0:string_end]
local_file = self.save_path + local_dir + '/' + re.findall(r".com\D.*", file_url)[0][5:] # 阿里云文件名
else:
if len(item['mp3_url']) == 0:
continue
time_array = time.strptime(item['call_time'], '%Y-%m-%d %H:%M:%S') url = item['mp3_url']
local_dir = time.strftime('%Y%m%d', time_array) array = url.split('/')
local_file = self.save_path + local_dir + '/' + re.findall(r".com\D.*", file_url)[0][5:] local_file = self.save_path + local_dir + '/' + array[-1] # 容联云文件名
if len(local_file) == 0:
continue
if self.check_file(local_file): if self.check_file(local_file):
old_num = old_num + 1 old_num = old_num + 1
...@@ -218,12 +230,8 @@ class DownFile: ...@@ -218,12 +230,8 @@ class DownFile:
self.log('download_over', '') self.log('download_over', '')
# today = datetime.date.today() # start_url = "https://api.tonglianjituan.com/task/getDownVoiceParamsReport?source=3&call_date=2019-12-10"
# one_day = datetime.timedelta(days=1) # DownFile(start_url).start()
# yesterday = today - one_day
# params_url = "https://api.tonglianjituan.com/task/getDownVoiceParamsReport?page_size=3000&source=3&call_date=" + str(yesterday)
start_url = "https://api.tonglianjituan.com/task/getDownVoiceParamsReport?source=3&call_date=2019-12-10"
# DownFile(params_url).start()
# #
params_url = "https://api.tonglianjituan.com/task/getDownVoiceParamsReport?source=3" params_url = "https://api.tonglianjituan.com/task/getDownVoiceParamsReport?source=3"
save_path = "/data/html/tl_estate/public/static/voice/" save_path = "/data/html/tl_estate/public/static/voice/"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment