Page MenuHomePhabricator

get_user_recordings_test.py
No OneTemporary

get_user_recordings_test.py

"""
获取用户数据
"""
import os
import time
import glob
import json
import librosa
import soundfile
from script.common import *
def exec_cmd(cmd):
r = os.popen(cmd)
text = r.read()
r.close()
return text
def get_d(audio_path):
cmd = "ffprobe -v quiet -print_format json -show_format -show_streams {}".format(audio_path)
data = exec_cmd(cmd)
data = json.loads(data)
if "format" in data.keys():
if "duration" in data['format']:
return float(data["format"]["duration"])
return 0
def get_user_recordings(user_id):
sm_ids = [
4148090438,
4148090458,
4148090494,
4148090510,
4148090514,
4148090534,
4148090546,
4148090574,
4148090582,
4148090606,
4148090622,
4148090646,
4148090678,
4148090718,
4148090750,
4148090786,
4148090810,
4148090834,
4148090858,
4148090866,
4148090886,
4148090902,
4148090922,
4148090934,
4148090970,
4148090986,
4148159561,
4148159581,
4148159593,
4148159673,
4148159721,
4148159729,
4148159757,
4148159781,
4148159789,
4148159797,
4148159833,
4148159841,
4148159881,
4148159949,
4148159965,
4148160013,
4148160021,
4148160037,
4148257127,
4148257179,
4148257215,
4148257251,
4148257263,
4148257271,
4148257303,
4148257307,
4148257311,
4148257323,
4148257335,
4148257343,
4148257383,
4148257419,
4148257427,
4148257431,
4148257439,
4148257447,
4148257451,
4148257471,
4148257483,
4148257491,
4148257551,
4148257575,
4148257615,
4148257623,
4148257627,
4148257631,
4148257655,
4148328480,
4148328492,
4148328552,
4148328564,
4148328580,
4148328588,
4148328592,
4148328600,
4148328608,
4148328660,
4148328668,
4148328728,
4148328788,
4148328804,
4148328828,
4148328868,
4148328900,
4148328928,
4148328944,
4148328972,
4148328988,
4148328996,
4148329008,
4148329012,
4148329016,
4148329028,
4148329076,
4148336302,
4148336310,
4148336314,
4148336334,
4148336350,
4148336366,
4148336386,
4148336390,
4148336406,
4148336418,
4148406433,
4148406441,
4148406445,
4148406449,
4148406469,
4148406473,
4148502907,
4148502911,
4148502915,
4148502931,
4148502947,
4148502951,
4148502963,
4148575184,
4148575208
]
all_map = {}
for sm_id in sm_ids:
sql = "select id, sm_id, song_id from recording where sm_id = {}".format(sm_id)
res = get_shard_data_by_sql(sql, user_id)
print("RES,{},{}".format(res[0][1], res[0][2]))
all_map[res[0][2]] = res[0][1]
# err_song_id = [
# 611752105030249319,
# 611752105030249338,
# 611752105030249355,
# 611752105030249370,
# 611752105030249385,
# 611752105030249397,
# 611752105030249410,
# 611752105030250739,
# 611752105030249030,
# 611752105030249030,
# 611752105030249040,
# 611752105030249070,
# 611752105030249113,
# 611752105030249174,
# 611752105030249227,
# 611752105030249273,
# 611752105030249287,
# 611752105030250691
# ]
# for song_id in err_song_id:
# print("err:{},{}".format(song_id, all_map[song_id]))
if __name__ == '__main__':
get_user_recordings("1407374883605781")

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 18:48 (1 d, 19 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1325631
Default Alt Text
get_user_recordings_test.py (4 KB)

Event Timeline