HoneyTian commited on
Commit
d9e7644
·
1 Parent(s): eeaf31b
data/porter_tasks/{porter_task_chenjieshen_douyin_live_record_to_baidu_netdisk.json → porter_task_chenjieshen_douyin_live_record_to_hf_netdisk.json} RENAMED
@@ -1,187 +1,177 @@
1
  [
2
  {
3
- "enable": false,
4
  "type": "douyin_live_record",
5
  "room_name": "陈杰森资本NewBoombap",
6
  "room_id": "57544215290",
7
  "sec_user_id": "MS4wLjABAAAATGoBrO7yiJ3q9go4fxq9JXjrnP1bFpdkgKckC1IpfXA_vrjSmL9ZtjmTju8ApwbT",
8
  "key_of_credentials": "douyin_wentao_credentials",
9
  "check_interval": 10,
10
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
11
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
12
  },
13
  {
14
- "enable": false,
15
  "type": "douyin_live_record",
16
  "room_name": "老陈的退路",
17
  "room_id": "330025930592",
18
  "sec_user_id": "MS4wLjABAAAAzjLy7Dd3Q-UiMGdkwymLhDIL1aFJtruvCUqrwmph9n8Zb55E4y9XH2WEFaLC1ZBl",
19
  "key_of_credentials": "douyin_wentao_credentials",
20
  "check_interval": 10,
21
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
22
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
23
  },
24
  {
25
- "enable": false,
26
  "type": "douyin_live_record",
27
  "room_name": "老陈come_back",
28
  "room_id": "78835697536",
29
  "sec_user_id": "MS4wLjABAAAAj3qTpPkes0t5az2nXd1oaag5TpOJeNh27pemT17WUVXHGUZKZfjqc3fFc8arL6V1",
30
  "key_of_credentials": "douyin_wentao_credentials",
31
  "check_interval": 10,
32
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
33
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
34
  },
35
  {
36
- "enable": false,
37
  "type": "douyin_live_record",
38
  "room_name": "清源第一帅",
39
  "room_id": "654177813521",
40
  "sec_user_id": "MS4wLjABAAAAtwkRNs5Krtm5cBhKzn60poflAFWdnYdwMf0I0M27rOGvNn2l16DfUH5vE3WL-ypz",
41
  "key_of_credentials": "douyin_wentao_credentials",
42
  "check_interval": 10,
43
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
44
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
45
  },
46
  {
47
- "enable": false,
48
  "type": "douyin_live_record",
49
  "room_name": "清源第二帅",
50
  "room_id": "831568261978",
51
  "sec_user_id": "MS4wLjABAAAALbRezHNzlaRYhk9QE-5ajImgcvfJGq9koAlD0O8VQwiC-N8Bqx2WDW07wLee2Bwd",
52
  "key_of_credentials": "douyin_wentao_credentials",
53
  "check_interval": 10,
54
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
55
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
56
  },
57
  {
58
- "enable": false,
59
  "type": "douyin_live_record",
60
  "room_name": "清源第三帅",
61
  "room_id": "26569028431",
62
  "sec_user_id": "MS4wLjABAAAA60pV9JuZNTZhQJeSI_AeaRUnKXs--TGPZEAtsgihwKnir46ncFVtLSO79JDnclkM",
63
  "key_of_credentials": "douyin_wentao_credentials",
64
  "check_interval": 10,
65
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
66
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
67
  },
68
  {
69
- "enable": false,
70
  "type": "douyin_live_record",
71
  "room_name": "清源第四帅",
72
  "room_id": "91434255754",
73
  "sec_user_id": "MS4wLjABAAAAakYu9rpF6vk50XbiKFnxzuXVv6fhVK5O3tr0gxjTJq2Nw5HfMplPv6ce6AhXxReG",
74
  "key_of_credentials": "douyin_wentao_credentials",
75
  "check_interval": 10,
76
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
77
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
78
  },
79
  {
80
- "enable": false,
81
  "type": "douyin_live_record",
82
  "room_name": "清源第五帅",
83
  "room_id": "469245033355",
84
  "sec_user_id": "MS4wLjABAAAA62G-uDXdlIPnk44P9gXhQQo1UmOCgZ08QWOP_-t4PjI",
85
  "key_of_credentials": "douyin_wentao_credentials",
86
  "check_interval": 10,
87
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
88
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
89
  },
90
  {
91
- "enable": false,
92
  "type": "douyin_live_record",
93
  "room_name": "清源人工智能研究院",
94
  "room_id": "81728900292",
95
  "sec_user_id": "MS4wLjABAAAAe_Hf6esmopqIMG7OhsMlNESTiqP1ot7lmGzK6Cu3pJSSGTOiHlI4cA33OPWg56Ql",
96
  "key_of_credentials": "douyin_wentao_credentials",
97
  "check_interval": 10,
98
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
99
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
100
  },
101
  {
102
- "enable": false,
103
  "type": "douyin_live_record",
104
  "room_name": "廖勇-清源政策研究院AIGC",
105
  "room_id": "gubenqingyuan",
106
  "sec_user_id": "MS4wLjABAAAA9ne6zoCLjnzpCRR1GhPVBUq2_7wIJO4GyZXlyW016yw",
107
  "key_of_credentials": "douyin_wentao_credentials",
108
  "check_interval": 10,
109
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
110
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
111
  },
112
  {
113
- "enable": false,
114
  "type": "douyin_live_record",
115
  "room_name": "小熊Bella与老爸",
116
  "room_id": "139751520143",
117
  "sec_user_id": "MS4wLjABAAAA49QFP6YhorLIIX9M-FiZeKxmqhqXlttluSsZeaxvxzU",
118
  "key_of_credentials": "douyin_wentao_credentials",
119
  "check_interval": 10,
120
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
121
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
122
  },
123
  {
124
- "enable": false,
125
  "type": "douyin_live_record",
126
  "room_name": "清源之虎",
127
  "room_id": "998621457719",
128
  "sec_user_id": "MS4wLjABAAAAWYFqu46IMCnfwgSjBK35RnQcKOYhqVX3YcP4rotpHkdxJn5JD59REMz5fwlccp2h",
129
  "key_of_credentials": "douyin_wentao_credentials",
130
  "check_interval": 10,
131
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
132
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
133
  },
134
  {
135
- "enable": false,
136
  "type": "douyin_live_record",
137
  "room_name": "老陈真是好人",
138
  "room_id": "599130203190",
139
  "sec_user_id": "MS4wLjABAAAA3ReegyjpprzeurqHUl8yLBkTlQ7L4TfoyjpDXeiy1RvCu7OmqWljOLmWgibTjs8y",
140
  "key_of_credentials": "douyin_wentao_credentials",
141
  "check_interval": 10,
142
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
143
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
144
  },
145
  {
146
- "enable": false,
147
  "type": "douyin_live_record",
148
  "room_name": "老陈小帮手",
149
  "room_id": "738682070097",
150
  "sec_user_id": "MS4wLjABAAAAtzZsG1mKtZvgE2j58ZB7FDRP1gzsHXuQDIN15bltkLM",
151
  "key_of_credentials": "douyin_wentao_credentials",
152
  "check_interval": 10,
153
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
154
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
155
- },
156
- {
157
- "enable": false,
158
- "type": "douyin_live_record",
159
- "room_name": "焦虑个锤子",
160
- "room_id": "78933304321",
161
- "sec_user_id": "MS4wLjABAAAAfr5os1dB5zdm36GK5nHVQkWReaELMueuYqliVDBo64Y",
162
- "key_of_credentials": "douyin_wentao_credentials",
163
- "check_interval": 10,
164
- "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森",
165
- "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json"
166
  },
167
  {
168
- "enable": false,
169
  "type": "video_format_convert",
170
- "task_name": "陈杰森-百度云盘-格式转换",
171
- "video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/file_info.json",
172
- "target_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/to_baidu_netdisk",
173
  "check_interval": 10,
174
  "remove_after_upload": true,
175
  "format_pairs": [["flv", "mp4"]]
176
  },
177
  {
178
  "enable": true,
179
- "type": "file_to_baidu_netdisk",
180
  "task_name": "陈杰森",
181
- "src_dir": "data/tasks/chenjieshen_douyin_live_record_to_baidu_netdisk/live_record/陈杰森/to_baidu_netdisk",
182
- "tgt_dir": "xianyu/customers/{task_name}/{date_str}",
 
183
  "check_interval": 10,
184
- "key_of_credentials": "baidu_netdisk_honeytian_credentials",
185
  "remove_after_upload": true,
186
  "exclude_files": "file_info.json"
187
  }
 
1
  [
2
  {
3
+ "enable": true,
4
  "type": "douyin_live_record",
5
  "room_name": "陈杰森资本NewBoombap",
6
  "room_id": "57544215290",
7
  "sec_user_id": "MS4wLjABAAAATGoBrO7yiJ3q9go4fxq9JXjrnP1bFpdkgKckC1IpfXA_vrjSmL9ZtjmTju8ApwbT",
8
  "key_of_credentials": "douyin_wentao_credentials",
9
  "check_interval": 10,
10
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
11
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
12
  },
13
  {
14
+ "enable": true,
15
  "type": "douyin_live_record",
16
  "room_name": "老陈的退路",
17
  "room_id": "330025930592",
18
  "sec_user_id": "MS4wLjABAAAAzjLy7Dd3Q-UiMGdkwymLhDIL1aFJtruvCUqrwmph9n8Zb55E4y9XH2WEFaLC1ZBl",
19
  "key_of_credentials": "douyin_wentao_credentials",
20
  "check_interval": 10,
21
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
22
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
23
  },
24
  {
25
+ "enable": true,
26
  "type": "douyin_live_record",
27
  "room_name": "老陈come_back",
28
  "room_id": "78835697536",
29
  "sec_user_id": "MS4wLjABAAAAj3qTpPkes0t5az2nXd1oaag5TpOJeNh27pemT17WUVXHGUZKZfjqc3fFc8arL6V1",
30
  "key_of_credentials": "douyin_wentao_credentials",
31
  "check_interval": 10,
32
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
33
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
34
  },
35
  {
36
+ "enable": true,
37
  "type": "douyin_live_record",
38
  "room_name": "清源第一帅",
39
  "room_id": "654177813521",
40
  "sec_user_id": "MS4wLjABAAAAtwkRNs5Krtm5cBhKzn60poflAFWdnYdwMf0I0M27rOGvNn2l16DfUH5vE3WL-ypz",
41
  "key_of_credentials": "douyin_wentao_credentials",
42
  "check_interval": 10,
43
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
44
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
45
  },
46
  {
47
+ "enable": true,
48
  "type": "douyin_live_record",
49
  "room_name": "清源第二帅",
50
  "room_id": "831568261978",
51
  "sec_user_id": "MS4wLjABAAAALbRezHNzlaRYhk9QE-5ajImgcvfJGq9koAlD0O8VQwiC-N8Bqx2WDW07wLee2Bwd",
52
  "key_of_credentials": "douyin_wentao_credentials",
53
  "check_interval": 10,
54
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
55
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
56
  },
57
  {
58
+ "enable": true,
59
  "type": "douyin_live_record",
60
  "room_name": "清源第三帅",
61
  "room_id": "26569028431",
62
  "sec_user_id": "MS4wLjABAAAA60pV9JuZNTZhQJeSI_AeaRUnKXs--TGPZEAtsgihwKnir46ncFVtLSO79JDnclkM",
63
  "key_of_credentials": "douyin_wentao_credentials",
64
  "check_interval": 10,
65
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
66
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
67
  },
68
  {
69
+ "enable": true,
70
  "type": "douyin_live_record",
71
  "room_name": "清源第四帅",
72
  "room_id": "91434255754",
73
  "sec_user_id": "MS4wLjABAAAAakYu9rpF6vk50XbiKFnxzuXVv6fhVK5O3tr0gxjTJq2Nw5HfMplPv6ce6AhXxReG",
74
  "key_of_credentials": "douyin_wentao_credentials",
75
  "check_interval": 10,
76
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
77
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
78
  },
79
  {
80
+ "enable": true,
81
  "type": "douyin_live_record",
82
  "room_name": "清源第五帅",
83
  "room_id": "469245033355",
84
  "sec_user_id": "MS4wLjABAAAA62G-uDXdlIPnk44P9gXhQQo1UmOCgZ08QWOP_-t4PjI",
85
  "key_of_credentials": "douyin_wentao_credentials",
86
  "check_interval": 10,
87
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
88
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
89
  },
90
  {
91
+ "enable": true,
92
  "type": "douyin_live_record",
93
  "room_name": "清源人工智能研究院",
94
  "room_id": "81728900292",
95
  "sec_user_id": "MS4wLjABAAAAe_Hf6esmopqIMG7OhsMlNESTiqP1ot7lmGzK6Cu3pJSSGTOiHlI4cA33OPWg56Ql",
96
  "key_of_credentials": "douyin_wentao_credentials",
97
  "check_interval": 10,
98
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
99
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
100
  },
101
  {
102
+ "enable": true,
103
  "type": "douyin_live_record",
104
  "room_name": "廖勇-清源政策研究院AIGC",
105
  "room_id": "gubenqingyuan",
106
  "sec_user_id": "MS4wLjABAAAA9ne6zoCLjnzpCRR1GhPVBUq2_7wIJO4GyZXlyW016yw",
107
  "key_of_credentials": "douyin_wentao_credentials",
108
  "check_interval": 10,
109
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
110
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
111
  },
112
  {
113
+ "enable": true,
114
  "type": "douyin_live_record",
115
  "room_name": "小熊Bella与老爸",
116
  "room_id": "139751520143",
117
  "sec_user_id": "MS4wLjABAAAA49QFP6YhorLIIX9M-FiZeKxmqhqXlttluSsZeaxvxzU",
118
  "key_of_credentials": "douyin_wentao_credentials",
119
  "check_interval": 10,
120
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
121
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
122
  },
123
  {
124
+ "enable": true,
125
  "type": "douyin_live_record",
126
  "room_name": "清源之虎",
127
  "room_id": "998621457719",
128
  "sec_user_id": "MS4wLjABAAAAWYFqu46IMCnfwgSjBK35RnQcKOYhqVX3YcP4rotpHkdxJn5JD59REMz5fwlccp2h",
129
  "key_of_credentials": "douyin_wentao_credentials",
130
  "check_interval": 10,
131
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
132
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
133
  },
134
  {
135
+ "enable": true,
136
  "type": "douyin_live_record",
137
  "room_name": "老陈真是好人",
138
  "room_id": "599130203190",
139
  "sec_user_id": "MS4wLjABAAAA3ReegyjpprzeurqHUl8yLBkTlQ7L4TfoyjpDXeiy1RvCu7OmqWljOLmWgibTjs8y",
140
  "key_of_credentials": "douyin_wentao_credentials",
141
  "check_interval": 10,
142
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
143
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
144
  },
145
  {
146
+ "enable": true,
147
  "type": "douyin_live_record",
148
  "room_name": "老陈小帮手",
149
  "room_id": "738682070097",
150
  "sec_user_id": "MS4wLjABAAAAtzZsG1mKtZvgE2j58ZB7FDRP1gzsHXuQDIN15bltkLM",
151
  "key_of_credentials": "douyin_wentao_credentials",
152
  "check_interval": 10,
153
+ "output_video_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森",
154
+ "output_video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json"
 
 
 
 
 
 
 
 
 
 
 
155
  },
156
  {
157
+ "enable": true,
158
  "type": "video_format_convert",
159
+ "task_name": "陈杰森",
160
+ "video_info_file": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/file_info.json",
161
+ "target_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/ready_to_hf_netdisk",
162
  "check_interval": 10,
163
  "remove_after_upload": true,
164
  "format_pairs": [["flv", "mp4"]]
165
  },
166
  {
167
  "enable": true,
168
+ "type": "file_to_hf_netdisk",
169
  "task_name": "陈杰森",
170
+ "src_dir": "data/tasks/chenjieshen_douyin_live_record_to_hf_netdisk/live_record/陈杰森/ready_to_hf_netdisk",
171
+ "tgt_dir": "xianyu/customers/陈杰森/{date_str}",
172
+ "repo_id": "tianxing1994/hf_netdisk",
173
  "check_interval": 10,
174
+ "key_of_credentials": "hf_miyuki_write_token",
175
  "remove_after_upload": true,
176
  "exclude_files": "file_info.json"
177
  }
toolbox/hf_netdisk/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ if __name__ == "__main__":
6
+ pass
toolbox/hf_netdisk/hf_netdisk_client.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import argparse
4
+ import json
5
+ import logging
6
+ import shutil
7
+ import tempfile
8
+ from pathlib import Path
9
+
10
+ import requests
11
+ from huggingface_hub import HfApi, login
12
+
13
+ from project_settings import project_path, environment
14
+ from toolbox.design_patterns.singleton import ParamsSingleton
15
+
16
+
17
+ logger = logging.getLogger("toolbox")
18
+
19
+
20
+ class HfNetdiskClient(ParamsSingleton):
21
+
22
+ def __init__(self, hf_token: str = None):
23
+ if not self._initialized:
24
+ self.hf_token = hf_token
25
+
26
+ self.hf_api = HfApi(token=hf_token)
27
+
28
+ self._initialized = True
29
+
30
+ def check_login(self):
31
+ flag = False
32
+ try:
33
+ user_info = self.hf_api.whoami()
34
+ user_info = json.dumps(user_info, ensure_ascii=False)
35
+ flag = True
36
+ except requests.exceptions.HTTPError as error:
37
+ user_info = f"whoami failed; error type: {type(error)}, error text: {str(error)}"
38
+ except Exception as error:
39
+ user_info = f"whoami failed; error type: {type(error)}, error text: {str(error)}"
40
+
41
+ logger.info(f"login flag: {flag}, user_info: {user_info}")
42
+ return flag
43
+
44
+
45
+ def get_args():
46
+ parser = argparse.ArgumentParser()
47
+ parser.add_argument(
48
+ "--key_of_credentials",
49
+ default="hf_miyuki_write_token",
50
+ type=str,
51
+ )
52
+ args = parser.parse_args()
53
+ return args
54
+
55
+
56
+ def main():
57
+ args = get_args()
58
+
59
+ import log
60
+ from project_settings import environment, project_path, log_directory, time_zone_info
61
+
62
+ log.setup_size_rotating(log_directory=log_directory, tz_info=time_zone_info)
63
+
64
+ hf_token = environment.get(key=args.key_of_credentials)
65
+
66
+ client = HfNetdiskClient(
67
+ hf_token=hf_token,
68
+ )
69
+
70
+ client.check_login()
71
+
72
+
73
+ return
74
+
75
+
76
+ if __name__ == "__main__":
77
+ main()
toolbox/hf_netdisk/netdisk/netdisk_client.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import argparse
4
+ from typing import List
5
+
6
+ from huggingface_hub.hf_api import CommitInfo
7
+
8
+ from project_settings import project_path
9
+ from toolbox.hf_netdisk.netdisk.repo_client import RepoClient
10
+
11
+
12
+ class NetdiskClient(RepoClient):
13
+ def __init__(self, hf_token: str):
14
+ super(NetdiskClient, self).__init__(hf_token=hf_token)
15
+
16
+ def upload_file(self, src_file, tgt_file, repo_id: str) -> str:
17
+ self.make_sure_repo(repo_id)
18
+ tgt_file_url = self.hf_api.upload_file(
19
+ path_or_fileobj=src_file,
20
+ path_in_repo=tgt_file,
21
+ repo_id=repo_id,
22
+ repo_type="dataset"
23
+ )
24
+ return tgt_file_url
25
+
26
+ def query_files(self, repo_id: str) -> List[str]:
27
+ result: List[str] = self.hf_api.list_repo_files(
28
+ repo_id=repo_id,
29
+ repo_type="dataset"
30
+ )
31
+ return result
32
+
33
+ def delete_file(self, path_in_repo: str, repo_id: str) -> str:
34
+ result: CommitInfo = self.hf_api.delete_file(
35
+ path_in_repo=path_in_repo,
36
+ repo_id=repo_id,
37
+ repo_type="dataset"
38
+ )
39
+ return result
40
+
41
+
42
+ def get_args():
43
+ parser = argparse.ArgumentParser()
44
+ parser.add_argument(
45
+ "--key_of_credentials",
46
+ default="hf_miyuki_write_token",
47
+ type=str,
48
+ )
49
+ parser.add_argument(
50
+ "--src_file",
51
+ default=(project_path / "README.md").as_posix(),
52
+ type=str,
53
+ )
54
+ parser.add_argument(
55
+ "--tgt_file",
56
+ default="video_platform/upload/README.md",
57
+ type=str,
58
+ )
59
+ args = parser.parse_args()
60
+ return args
61
+
62
+
63
+ def main():
64
+ args = get_args()
65
+
66
+ import log
67
+ from project_settings import environment, project_path, log_directory, time_zone_info
68
+
69
+ log.setup_size_rotating(log_directory=log_directory, tz_info=time_zone_info)
70
+
71
+ hf_token = environment.get(key=args.key_of_credentials)
72
+
73
+ client = NetdiskClient(
74
+ hf_token=hf_token,
75
+ )
76
+
77
+ result = client.upload_file(
78
+ repo_id="tianxing1994/hf_netdisk",
79
+ src_file=args.src_file,
80
+ tgt_file=args.tgt_file,
81
+ )
82
+ print(result)
83
+
84
+ result = client.query_files(
85
+ repo_id="tianxing1994/hf_netdisk",
86
+ )
87
+ print(result)
88
+
89
+ result = client.delete_file(
90
+ path_in_repo=args.tgt_file,
91
+ repo_id="tianxing1994/hf_netdisk",
92
+ )
93
+ print(result)
94
+ return
95
+
96
+
97
+ if __name__ == "__main__":
98
+ main()
toolbox/hf_netdisk/netdisk/repo_client.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import argparse
4
+
5
+ from toolbox.hf_netdisk.hf_netdisk_client import HfNetdiskClient
6
+
7
+
8
+ class RepoClient(HfNetdiskClient):
9
+ def __init__(self, hf_token: str):
10
+ super(RepoClient, self).__init__(hf_token=hf_token)
11
+
12
+ def create_repo(self, repo_id: str) -> str:
13
+ self.hf_api.create_repo(
14
+ repo_id=repo_id,
15
+ repo_type="dataset",
16
+ private=False,
17
+ exist_ok=True
18
+ )
19
+ return repo_id
20
+
21
+ def delete_repo(self, repo_id: str) -> str:
22
+ self.hf_api.delete_repo(
23
+ repo_id=repo_id,
24
+ repo_type="dataset",
25
+ missing_ok=True
26
+ )
27
+ return repo_id
28
+
29
+ def check_repo(self, repo_id: str) -> bool:
30
+ exists: bool = self.hf_api.repo_exists(
31
+ repo_id=repo_id,
32
+ repo_type="dataset",
33
+ )
34
+ return exists
35
+
36
+ def make_sure_repo(self, repo_id: str) -> bool:
37
+ exists: bool = self.hf_api.repo_exists(
38
+ repo_id=repo_id,
39
+ repo_type="dataset",
40
+ )
41
+ if exists is not True:
42
+ self.hf_api.create_repo(
43
+ repo_id=repo_id,
44
+ repo_type="dataset",
45
+ private=False,
46
+ exist_ok=True
47
+ )
48
+ exists: bool = self.hf_api.repo_exists(
49
+ repo_id=repo_id,
50
+ repo_type="dataset",
51
+ )
52
+ return exists
53
+
54
+
55
+ def get_args():
56
+ parser = argparse.ArgumentParser()
57
+ parser.add_argument(
58
+ "--key_of_credentials",
59
+ default="hf_miyuki_write_token",
60
+ type=str,
61
+ )
62
+ args = parser.parse_args()
63
+ return args
64
+
65
+
66
+ def main():
67
+ args = get_args()
68
+
69
+ import log
70
+ from project_settings import environment, project_path, log_directory, time_zone_info
71
+
72
+ log.setup_size_rotating(log_directory=log_directory, tz_info=time_zone_info)
73
+
74
+ hf_token = environment.get(key=args.key_of_credentials)
75
+
76
+ client = RepoClient(
77
+ hf_token=hf_token,
78
+ )
79
+
80
+ flag = client.check_repo("tianxing1994/hf_netdisk")
81
+ print(f"flag: {flag}")
82
+ repo_id = client.create_repo("tianxing1994/hf_netdisk")
83
+ flag = client.check_repo("tianxing1994/hf_netdisk")
84
+ print(f"flag: {flag}")
85
+ repo_id = client.delete_repo("tianxing1994/hf_netdisk")
86
+ flag = client.check_repo("tianxing1994/hf_netdisk")
87
+ print(f"flag: {flag}")
88
+
89
+ return
90
+
91
+
92
+ if __name__ == "__main__":
93
+ main()
toolbox/porter/tasks/__init__.py CHANGED
@@ -6,6 +6,7 @@ from .douyin_video_download_task import DouyinVideoDownloadTask
6
  from .douyin_live_record_task import DouyinLiveRecordTask
7
  from .douyin_live_to_bilibili_live_task import DouyinLiveToBilibiliLiveTask
8
  from .file_to_baidu_netdisk_task import FileToBaiduNetdiskTask
 
9
  from .video_format_convert_task import VideoFormatConvertTask
10
  from .video_to_bilibili_task import VideoToBilibiliTask
11
  from .video_to_youtube_task import VideoToYoutubeTask
 
6
  from .douyin_live_record_task import DouyinLiveRecordTask
7
  from .douyin_live_to_bilibili_live_task import DouyinLiveToBilibiliLiveTask
8
  from .file_to_baidu_netdisk_task import FileToBaiduNetdiskTask
9
+ from .file_to_hf_netdisk_task import FileToHfNetdiskTask
10
  from .video_format_convert_task import VideoFormatConvertTask
11
  from .video_to_bilibili_task import VideoToBilibiliTask
12
  from .video_to_youtube_task import VideoToYoutubeTask
toolbox/porter/tasks/file_to_hf_netdisk_task.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import aiofiles
4
+ import asyncio
5
+ import copy
6
+ from datetime import datetime
7
+ from zoneinfo import ZoneInfo # Python 3.9+ 自带,无需安装
8
+ import logging
9
+ import json
10
+ import os
11
+ from pathlib import Path
12
+ from typing import Coroutine, Dict, List, Tuple, Union, Iterable
13
+
14
+ logger = logging.getLogger("toolbox")
15
+
16
+ from toolbox.porter.tasks.base_task import BaseTask
17
+ from toolbox.hf_netdisk.netdisk.netdisk_client import NetdiskClient
18
+ from project_settings import environment, project_path, time_zone_info
19
+
20
+
21
+ @BaseTask.register("file_to_hf_netdisk")
22
+ class FileToHfNetdiskTask(BaseTask):
23
+ def __init__(self,
24
+ task_name: str,
25
+ src_dir: str,
26
+ tgt_dir: str,
27
+ repo_id: str,
28
+ check_interval: int,
29
+ key_of_credentials: str,
30
+ remove_after_upload: bool = False,
31
+ exclude_files: List[str] = None,
32
+ **kwargs
33
+ ):
34
+ super().__init__(
35
+ flag=f"[{self.__class__.__name__}_{task_name}]",
36
+ check_interval=check_interval
37
+ )
38
+ self.task_name = task_name
39
+ self.tgt_dir: str = tgt_dir
40
+ # tgt_dir
41
+ # xianyu/customers/{task_name}/{date_str}/{time_str}
42
+ self.repo_id: str = repo_id
43
+
44
+ self.remove_after_upload = remove_after_upload
45
+ self.exclude_files = exclude_files or list()
46
+ self.key_of_credentials = key_of_credentials
47
+
48
+ if not os.path.isabs(src_dir):
49
+ self.src_dir: Path = project_path / src_dir
50
+ else:
51
+ self.src_dir: Path = Path(src_dir)
52
+
53
+ hf_token = environment.get(self.key_of_credentials, dtype=str)
54
+ self.client = NetdiskClient(hf_token=hf_token)
55
+
56
+ async def do_task(self):
57
+ for filename in self.src_dir.glob("*"):
58
+ name = filename.name
59
+ if name in self.exclude_files:
60
+ continue
61
+
62
+ date_now_str = datetime.now().strftime("%Y%m%d")
63
+ time_now_str = datetime.now().strftime("%H%M%S")
64
+
65
+ kwargs = {
66
+ "task_name": self.task_name,
67
+ "date_str": date_now_str,
68
+ "time_str": time_now_str,
69
+ }
70
+
71
+ tgt_dir = self.tgt_dir.format(**kwargs)
72
+ tgt_file = Path(tgt_dir) / name
73
+
74
+ logger.info(f"{self.flag}上传视频; repo_id: {self.repo_id}, src_file: {filename.as_posix()}, tgt_file: {tgt_file.as_posix()}")
75
+ # _ = await asyncio.to_thread(
76
+ # self.client.upload_file,
77
+ # src_file=filename.as_posix(),
78
+ # tgt_file=tgt_file.as_posix()
79
+ # )
80
+ tgt_file_url: str = self.client.upload_file(
81
+ src_file=filename.as_posix(),
82
+ tgt_file=tgt_file.as_posix(),
83
+ repo_id=self.repo_id,
84
+ )
85
+ if self.remove_after_upload:
86
+ logger.info(f"{self.flag}删除本地文件:{filename.as_posix()}")
87
+ os.remove(filename.as_posix())
88
+ logger.info(f"{self.flag}上传视频成功; local_file: {filename.as_posix()}, remote:file: {tgt_file_url}")
89
+
90
+
91
+ def main():
92
+ return
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
toolbox/porter/tasks/video_format_convert_task.py CHANGED
@@ -62,7 +62,6 @@ class VideoFormatConvertTask(BaseTask):
62
 
63
  async def do_task(self):
64
  video_info = await self.load_video_info()
65
- print(self.video_info_file)
66
 
67
  new_video_info = copy.deepcopy(video_info)
68
  for k, v in video_info.items():
@@ -104,9 +103,8 @@ class VideoFormatConvertTask(BaseTask):
104
  output_file = self.target_dir / output_file.name
105
  output_file.parent.mkdir(parents=True, exist_ok=True)
106
 
107
- idx = uuid.uuid4()
108
- input_file_ = input_file.parent / f"{idx}{input_file.suffix}"
109
- output_file_ = output_file.parent / f"{idx}{output_file.suffix}"
110
  os.rename(input_file.as_posix(), input_file_.as_posix())
111
 
112
  command = [
 
62
 
63
  async def do_task(self):
64
  video_info = await self.load_video_info()
 
65
 
66
  new_video_info = copy.deepcopy(video_info)
67
  for k, v in video_info.items():
 
103
  output_file = self.target_dir / output_file.name
104
  output_file.parent.mkdir(parents=True, exist_ok=True)
105
 
106
+ input_file_ = input_file.parent / f"{uuid.uuid4()}{input_file.suffix}"
107
+ output_file_ = input_file.parent / f"{uuid.uuid4()}{output_file.suffix}"
 
108
  os.rename(input_file.as_posix(), input_file_.as_posix())
109
 
110
  command = [