-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
pan.baidu.com.py
executable file
·4143 lines (3704 loc) · 147 KB
/
pan.baidu.com.py
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python2
# vim: set fileencoding=utf8
import os
import sys
import hashlib
import functools
import requests
requests.packages.urllib3.disable_warnings() # disable urllib3's warnings https://urllib3.readthedocs.org/en/latest/security.html#insecurerequestwarning
from requests_toolbelt import MultipartEncoder
import urllib
import json
import cPickle as pk
import re
import time
import argparse
from random import SystemRandom
random = SystemRandom()
import select
import base64
import md5
import rsa
from zlib import crc32
import cStringIO
import signal
############################################################
# Defines that should never be changed
OneK = 1024
OneM = OneK * OneK
OneG = OneM * OneK
OneT = OneG * OneK
OneP = OneT * OneK
OneE = OneP * OneK
############################################################
# Default values
MinRapidUploadFileSize = 256 * OneK
DefaultSliceSize = 10 * OneM
MaxSliceSize = 2 * OneG
MaxSlicePieces = 1024
ENoError = 0
CIPHERS = [
"aes-256-cfb", "aes-128-cfb", "aes-192-cfb",
"aes-256-ofb", "aes-128-ofb", "aes-192-ofb",
"aes-128-ctr", "aes-192-ctr", "aes-256-ctr",
"aes-128-cfb8", "aes-192-cfb8", "aes-256-cfb8",
"aes-128-cfb1", "aes-192-cfb1", "aes-256-cfb1",
"bf-cfb", "camellia-128-cfb", "camellia-192-cfb",
"camellia-256-cfb", "cast5-cfb", "chacha20",
"idea-cfb", "rc2-cfb", "rc4-md5", "salsa20", "seed-cfb"
]
############################################################
# 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."
}
############################################################
# file extensions
mediatype = [
".wma", ".wav", ".mp3", ".aac", ".ra", ".ram", ".mp2", ".ogg", \
".aif", ".mpega", ".amr", ".mid", ".midi", ".m4a", ".m4v", ".wmv", \
".rmvb", ".mpeg4", ".mpeg2", ".flv", ".avi", ".3gp", ".mpga", ".qt", \
".rm", ".wmz", ".wmd", ".wvx", ".wmx", ".wm", ".swf", ".mpg", ".mp4", \
".mkv", ".mpeg", ".mov", ".mdf", ".iso", ".asf", ".vob"
]
imagetype = [
".jpg", ".jpeg", ".gif", ".bmp", ".png", ".jpe", ".cur", ".svg", \
".svgz", ".tif", ".tiff", ".ico"
]
doctype = [
".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".vsd", ".txt", ".pdf", \
".ods", ".ots", ".odt", ".rtf", ".dot", ".dotx", ".odm", ".pps", ".pot", \
".xlt", ".xltx", ".csv", ".ppsx", ".potx", ".epub", ".apk", ".exe", \
".msi", ".ipa", ".torrent", ".mobi"
]
archivetype = [
".7z", ".a", ".ace", ".afa", ".alz", ".android", ".apk", ".ar", \
".arc", ".arj", ".b1", ".b1", ".ba", ".bh", ".bz2", ".cab", ".cab", \
".cfs", ".chm", ".cpio", ".cpt", ".cqm", ".dar", ".dd", ".dgc", ".dmg", \
".ear", ".ecc", ".eqe", ".exe", ".f", ".gca", ".gz", ".ha", ".hki", \
".html", ".ice", ".id", ".infl", ".iso", ".jar", ".kgb", ".lbr", \
".lha", ".lqr", ".lz", ".lzh", ".lzma", ".lzo", ".lzx", ".mar", ".ms", \
".net", ".package", ".pak", ".paq6", ".paq7", ".paq8", ".par", ".par2", \
".partimg", ".pea", ".pim", ".pit", ".qda", ".rar", ".rk", ".rz", \
".s7z", ".sda", ".sea", ".sen", ".sfark", ".sfx", ".shar", ".sit", \
".sitx", ".sqx", ".tar", ".tbz2", ".tgz", ".tlz", ".tqt", ".uc", \
".uc0", ".uc2", ".uca", ".ucn", ".ue2", ".uha", ".ur2", ".war", ".web", \
".wim", ".x", ".xar", ".xp3", ".xz", ".yz1", ".z", ".zip", ".zipx", \
".zoo", ".zpaq", ".zz"
]
PHONE_MODEL_DATABASE = [
"1501_M02", # 360 F4
"1503-M02", # 360 N4
"1505-A01", # 360 N4S
"303SH", # 夏普 Aquos Crystal Xx Mini 303SH
"304SH", # 夏普 Aquos Crystal Xx SoftBank
"305SH", # 夏普 Aquos Crystal Y
"306SH", # 夏普 Aquos Crystal 306SH
"360 Q5 Plus", # 360 Q5 Plus
"360 Q5", # 360 Q5
"402SH", # 夏普 Aquos Crystal X
"502SH", # 夏普 Aquos Crystal Xx2
"6607", # OPPO U3
"A1001", # 一加手机1
"ASUS_A001", # 华硕 ZenFone 3 Ultra
"ASUS_A001", # 华硕 ZenFone 3 Ultra
"ASUS_Z00ADB", # 华硕 ZenFone 2
"ASUS_Z00UDB", # 华硕 Zenfone Selfie
"ASUS_Z00XSB", # 华硕 ZenFone Zoom
"ASUS_Z012DE", # 华硕 ZenFone 3
"ASUS_Z012DE", # 华硕 ZenFone 3
"ASUS_Z016D", # 华硕 ZenFone 3 尊爵
"ATH-TL00H", # 华为 荣耀 7i
"Aster T", # Vertu Aster T
"BLN-AL10", # 华为 荣耀 畅玩6X
"BND-AL10", # 荣耀7X
"BTV-W09", # 华为 M3
"CAM-UL00", # 华为 荣耀 畅玩5A
"Constellation V", # Vertu Constellation V
"D6683", # 索尼 Xperia Z3 Dual TD
"DIG-AL00", # 华为 畅享 6S
"E2312", # 索尼 Xperia M4 Aqua
"E2363 ", # 索尼 Xperia M4 Aqua Dual
"E5363", # 索尼 Xperia C4
"E5563", # 索尼 Xperia C5
"E5663", # 索尼 Xperia M5
"E5823", # 索尼 Xperia Z5 Compact
"E6533", # 索尼 Xperia Z3+
"E6683", # 索尼 Xperia Z5
"E6883", # 索尼 Xperia Z5 Premium
"EBEN M2", # 8848 M2
"EDI-AL10", # 华为 荣耀 Note 8
"EVA-AL00", # 华为 P9
"F100A", # 金立 F100
"F103B", # 金立 F103B
"F3116", # 索尼 Xperia XA
"F3216", # 索尼 Xperia XA Ultra
"F5121 / F5122", # 索尼 Xperia X
"F5321", # 索尼 Xperia X Compact
"F8132", # 索尼 Xperia X Performance
"F8332", # 索尼 Xperia XZ
"FRD-AL00", # 华为 荣耀 8
"FS8001", # 夏普 C1
"FS8002", # 夏普 A1
"G0111", # 格力手机 1
"G0215", # 格力手机 2
"G8142", # 索尼Xperia XZ Premium G8142
"G8342", # 索尼Xperia XZ1
"GIONEE S9", # 金立 S9
"GN5001S", # 金立 金钢
"GN5003", # 金立 大金钢
"GN8002S", # 金立 M6 Plus
"GN8003", # 金立 M6
"GN9011", # 金立 S8
"GN9012", # 金立 S6 Pro
"GRA-A0", # Coolpad Cool Play 6C
"H60-L11", # 华为 荣耀 6
"HN3-U01", # 华为 荣耀 3
"HTC D10w", # HTC Desire 10 Pro
"HTC E9pw", # HTC One E9+
"HTC M10u", # HTC 10
"HTC M8St", # HTC One M8
"HTC M9PT", # HTC One M9+
"HTC M9e", # HTC One M9
"HTC One A9", # HTC One A9
"HTC U-1w", # HTC U Ultra
"HTC X9u", # HTC One X9
"HTC_M10h", # HTC 10 国际版
"HUAWEI CAZ-AL00", # 华为 Nova
"HUAWEI CRR-UL00", # 华为 Mate S
"HUAWEI GRA-UL10", # 华为 P8
"HUAWEI MLA-AL10", # 华为 麦芒 5
"HUAWEI MT7-AL00", # 华为 mate 7
"HUAWEI MT7-TL00", # 华为 Mate 7
"HUAWEI NXT-AL10", # 华为 Mate 8
"HUAWEI P7-L00", # 华为 P7
"HUAWEI RIO-AL00", # 华为 麦芒 4
"HUAWEI TAG-AL00", # 华为 畅享 5S
"HUAWEI VNS-AL00", # 华为 G9
"IUNI N1", # 艾优尼 N1
"IUNI i1", # 艾优尼 i1
"KFAPWI", # Amazon Kindle Fire HDX 8.9
"KFSOWI", # Amazon Kindle Fire HDX 7
"KFTHWI", # Amazon Kindle Fire HD
"KIW-TL00H", # 华为 荣耀 畅玩5X
"KNT-AL10", # 华为 荣耀 V8
"L55t", # 索尼 Xperia Z3
"L55u", # 索尼 Xperia Z3
"LEX626", # 乐视 乐S3
"LEX720", # 乐视 乐Pro3
"LG-D858", # LG G3
"LG-H818", # LG G4
"LG-H848", # LG G5 SE
"LG-H868", # LG G5
"LG-H968", # LG V10
"LON-AL00", # 华为 Mate 9 Pro
"LON-AL00-PD", # 华为 Mate 9 Porsche Design
"LT18i", # Sony Ericsson Xperia Arc S
"LT22i", # Sony Ericsson Xperia P
"LT26i", # Sony Ericsson Xperia S
"LT26ii", # Sony Ericsson Xperia SL
"LT26w", # Sony Ericsson Xperia Acro S
"Le X520", # 乐视 乐2
"Le X620", # 乐视 乐2Pro
"Le X820", # 乐视 乐Max2
"Lenovo A3580", # 联想 黄金斗士 A8 畅玩
"Lenovo A7600-m", # 联想 黄金斗士 S8
"Lenovo A938t", # 联想 黄金斗士 Note8
"Lenovo K10e70", # 联想 乐檬K10
"Lenovo K30-T", # 联想 乐檬 K3
"Lenovo K32C36", # 联想 乐檬3
"Lenovo K50-t3s", # 联想 乐檬 K3 Note
"Lenovo K52-T38", # 联想 乐檬 K5 Note
"Lenovo K52e78", # Lenovo K5 Note
"Lenovo P2c72", # 联想 P2
"Lenovo X3c50", # 联想 乐檬 X3
"Lenovo Z90-3", # 联想 VIBE Shot大拍
"M040", # 魅族 MX 2
"M1 E", # 魅蓝 E
"M2-801w", # 华为 M2
"M2017", # 金立 M2017
"M3", # EBEN M3
"M355", # 魅族 MX 3
"MHA-AL00", # 华为 Mate 9
"MI 4LTE", # 小米手机4
"MI 4S", # 小米手机4S
"MI 5", # 小米手机5
"MI 5s Plus", # 小米手机5s Plus
"MI 5s", # 小米手机5s
"MI MAX", # 小米Max
"MI Note Pro", # 小米Note顶配版
"MI PAD 2", # 小米平板 2
"MIX", # 小米MIX
"MLA-UL00", # 华为 G9 Plus
"MP1503", # 美图 M6
"MP1512", # 美图 M6s
"MT27i", # Sony Ericsson Xperia Sola
"MX4 Pro", # 魅族 MX 4 Pro
"MX4", # 魅族 MX 4
"MX5", # 魅族 MX 5
"MX6", # 魅族 MX 6
"Meitu V4s", # 美图 V4s
"Meizu M3 Max", # 魅蓝max
"Meizu U20", # 魅蓝U20
"Mi 5",
"Mi 6",
"Mi A1", # MI androidone
"Mi Note 2", # 小米Note2
"MiTV2S-48", # 小米电视2s
"Moto G (4)", # 摩托罗拉 G⁴ Plus
"N1", # Nokia N1
"NCE-AL00", # 华为 畅享 6
"NTS-AL00", # 华为 荣耀 Magic
"NWI-AL10", # nova2s
"NX508J", # 努比亚 Z9
"NX511J", # 努比亚 小牛4 Z9 Mini
"NX512J", # 努比亚 大牛 Z9 Max
"NX513J", # 努比亚 My 布拉格
"NX513J", # 努比亚 布拉格S
"NX523J", # 努比亚 Z11 Max
"NX529J", # 努比亚 小牛5 Z11 Mini
"NX531J", # 努比亚 Z11
"NX549J", # 努比亚 小牛6 Z11 MiniS
"NX563J", # 努比亚Z17
"Nexus 4",
"Nexus 5X",
"Nexus 6",
"Nexus 6P",
"Nexus 7",
"Nexus 9",
"Nokia_X", # Nokia X
"Nokia_XL_4G", # Nokia XL
"ONE A2001", # 一加手机2
"ONE E1001", # 一加手机X
"ONEPLUS A5010", # 一加5T
"OPPO A53", # OPPO A53
"OPPO A59M", # OPPO A59
"OPPO A59s", # OPPO A59s
"OPPO R11",
"OPPO R7", # OPPO R7
"OPPO R7Plus", # OPPO R7Plus
"OPPO R7S", # OPPO R7S
"OPPO R7sPlus", # OPPO R7sPlus
"OPPO R9 Plustm A", # OPPO R9Plus
"OPPO R9s Plus", # OPPO R9s Plus
"OPPO R9s",
"OPPO R9s", # OPPO R9s
"OPPO R9tm", # OPPO R9
"PE-TL10", # 华为 荣耀 6 Plus
"PLK-TL01H", # 华为 荣耀 7
"Pro 5", # 魅族 Pro 5
"Pro 6", # 魅族 Pro 6
"Pro 6s", # 魅族 Pro 6s
"RM-1010", # Nokia Lumia 638
"RM-1018", # Nokia Lumia 530
"RM-1087", # Nokia Lumia 930
"RM-1090", # Nokia Lumia 535
"RM-867", # Nokia Lumia 920
"RM-875", # Nokia Lumia 1020
"RM-887", # Nokia Lumia 720
"RM-892", # Nokia Lumia 925
"RM-927", # Nokia Lumia 929
"RM-937", # Nokia Lumia 1520
"RM-975", # Nokia Lumia 635
"RM-977", # Nokia Lumia 630
"RM-984", # Nokia Lumia 830
"RM-996", # Nokia Lumia 1320
"Redmi 3S", # 红米3s
"Redmi 4", # 小米 红米4
"Redmi 4A", # 小米 红米4A
"Redmi Note 2", # 小米 红米Note2
"Redmi Note 3", # 小米 红米Note3
"Redmi Note 4", # 小米 红米Note4
"Redmi Pro", # 小米 红米Pro
"S3", # 佳域S3
"SCL-TL00H", # 华为 荣耀 4A
"SD4930UR", # Amazon Fire Phone
"SH-03G", # 夏普 Aquos Zeta SH-03G
"SH-04F", # 夏普 Aquos Zeta SH-04F
"SHV31", # 夏普 Aquos Serie Mini SHV31
"SM-A5100", # Samsung Galaxy A5
"SM-A7100", # Samsung Galaxy A7
"SM-A8000", # Samsung Galaxy A8
"SM-A9000", # Samsung Galaxy A9
"SM-A9100", # Samsung Galaxy A9 高配版
"SM-C5000", # Samsung Galaxy C5
"SM-C5010", # Samsung Galaxy C5 Pro
"SM-C7000", # Samsung Galaxy C7
"SM-C7010", # Samsung Galaxy C7 Pro
"SM-C9000", # Samsung Galaxy C9 Pro
"SM-G1600", # Samsung Galaxy Folder
"SM-G5500", # Samsung Galaxy On5
"SM-G6000", # Samsung Galaxy On7
"SM-G7100", # Samsung Galaxy On7(2016)
"SM-G7200", # Samsung Galasy Grand Max
"SM-G9198", # Samsung 领世旗舰Ⅲ
"SM-G9208", # Samsung Galaxy S6
"SM-G9250", # Samsung Galasy S7 Edge
"SM-G9280", # Samsung Galaxy S6 Edge+
"SM-G9300", # Samsung Galaxy S7
"SM-G9350", # Samsung Galaxy S7 Edge
"SM-G9500", # Samsung Galaxy S8
"SM-G9550", # Samsung Galaxy S8+
"SM-G9600", # Samsung Galaxy S9
"SM-G960F", # Galaxy S9 Dual SIM
"SM-G9650", # Samsung Galaxy S9+
"SM-G965F", # Galaxy S9+ Dual SIM
"SM-J3109", # Samsung Galaxy J3
"SM-J3110", # Samsung Galaxy J3 Pro
"SM-J327A", # Samsung Galaxy J3 Emerge
"SM-J5008", # Samsung Galaxy J5
"SM-J7008", # Samsung Galaxy J7
"SM-N9108V", # Samsung Galasy Note4
"SM-N9200", # Samsung Galaxy Note5
"SM-N9300", # Samsung Galaxy Note 7
"SM-N935S", # Samsung Galaxy Note Fan Edition
"SM-N9500", # Samsung Galasy Note8
"SM-W2015", # Samsung W2015
"SM-W2016", # Samsung W2016
"SM-W2017", # Samsung W2017
"SM705", # 锤子 T1
"SM801", # 锤子 T2
"SM901", # 锤子 M1
"SM919", # 锤子 M1L
"ST18i", # Sony Ericsson Xperia Ray
"ST25i", # Sony Ericsson Xperia U
"STV100-1", # 黑莓Priv
"Signature Touch", # Vertu Signature Touch
"TA-1000", # Nokia 6
"TA-1000", # HMD Nokia 6
"TA-1041", # Nokia 7
"VERTU Ti", # Vertu Ti
"VIE-AL10", # 华为 P9 Plus
"VIVO X20",
"VIVO X20A",
"W909", # 金立 天鉴 W909
"X500", # 乐视 乐1S
"X608", # 乐视 乐1
"X800", # 乐视 乐1Pro
"X900", # 乐视 乐Max
"XT1085", # 摩托罗拉 X
"XT1570", # 摩托罗拉 X Style
"XT1581", # 摩托罗拉 X 极
"XT1585", # 摩托罗拉 Droid Turbo 2
"XT1635", # 摩托罗拉 Z Play
"XT1635-02", # 摩托罗拉 Z Play
"XT1650", # 摩托罗拉 Z
"XT1650-05", # 摩托罗拉 Z
"XT1706", # 摩托罗拉 E³ POWER
"YD201", # YotaPhone2
"YD206", # YotaPhone2
"YQ60", # 锤子 坚果
"ZTE A2015", # 中兴 AXON 天机
"ZTE A2017", # 中兴 AXON 天机 7
"ZTE B2015", # 中兴 AXON 天机 MINI
"ZTE BV0720", # 中兴 Blade A2
"ZTE BV0730", # 中兴 Blade A2 Plus
"ZTE C2016", # 中兴 AXON 天机 MAX
"ZTE C2017", # 中兴 AXON 天机 7 MAX
"ZTE G720C", # 中兴 星星2号
"ZUK Z2121", # ZUK Z2 Pro
"ZUK Z2131", # ZUK Z2
"ZUK Z2151", # ZUK Edge
"ZUK Z2155", # ZUK Edge L
"m030", # 魅族mx
"m1 metal", # 魅蓝metal
"m1 note", # 魅蓝 Note
"m1", # 魅蓝
"m2 note", # 魅蓝 Note 2
"m2", # 魅蓝 2
"m3 note", # 魅蓝 Note 3
"m3", # 魅蓝 3
"m3s", # 魅蓝 3S
"m9", # 魅族m9
"marlin", # Google Pixel XL
"sailfish", # Google Pixel
"vivo V3Max", # vivo V3Max
"vivo X6D", # vivo X6
"vivo X6PlusD", # vivo X6Plus
"vivo X6S", # vivo X6S
"vivo X6SPlus", # vivo X6SPlus
"vivo X7", # vivo X7
"vivo X7Plus", # vivo X7Plus
"vivo X9", # vivo X9
"vivo X9Plus", # vivo X9Plus
"vivo Xplay5A 金", # vivo Xplay5
"vivo Xplay6", # vivo Xplay6
"vivo Y66", # vivo Y66
"vivo Y67", # vivo Y67
"z1221", # ZUK Z1
]
s = '\x1b[%s;%sm%s\x1b[0m' # terminual color template
cookie_file = os.path.join(os.path.expanduser('~'), '.bp.cookies')
upload_datas_path = os.path.join(os.path.expanduser('~'), '.bp.pickle')
save_share_path = os.path.join(os.path.expanduser('~'), '.bp.ss.pickle')
headers = {
"Accept": "application/json, text/javascript, text/html, */*; q=0.01",
"Accept-Encoding":"gzip, deflate, sdch",
"Accept-Language":"en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2",
"Referer":"http://pan.baidu.com/disk/home",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36",
"Connection": "keep-alive",
}
NETDISK_UA = 'netdisk;8.12.9;;android-android;7.0;JSbridge3.0.0'
ss = requests.session()
ss.headers.update(headers)
def to_md5(buff):
assert isinstance(buff, (str, unicode))
if isinstance(buff, unicode):
buff = buff.encode('utf-8')
return hashlib.md5(buff).hexdigest()
def to_sha1(buff):
assert isinstance(buff, (str, unicode))
if isinstance(buff, unicode):
buff = buff.encode('utf-8')
return hashlib.sha1(buff).hexdigest()
# 根据key计算出imei
def sum_IMEI(key):
hs = 53202347234687234
for k in key:
hs += (hs << 5) + ord(k)
hs %= int(1e15)
if hs < int(1e14):
hs += int(1e14)
return str(int(hs))
# 根据key, 从 PHONE_MODEL_DATABASE 中取出手机型号
def get_phone_model(key):
if len(PHONE_MODEL_DATABASE) <= 0:
return "S3"
hs = 2134
for k in key:
hs += (hs << 4) + ord(k)
hs %= len(PHONE_MODEL_DATABASE)
return PHONE_MODEL_DATABASE[hs]
def import_shadowsocks():
try:
global encrypt
from shadowsocks import encrypt
except ImportError:
print s % (1, 93, ' !! you don\'t install shadowsocks for python2.')
print s % (1, 97, ' install shadowsocks:')
print s % (1, 92, ' pip2 install shadowsocks')
sys.exit(1)
def get_abspath(pt):
if '~' == pt[0]:
path = os.path.expanduser(pt)
else:
path = os.path.abspath(pt)
if os.path.exists(path):
return path
else:
print s % (1, 91, ' !! path isn\'t existed.'), pt
return None
def make_server_path(cwd, path):
def cd(cwd, part):
if part == '..':
cwd = os.path.dirname(cwd)
elif part == '.':
pass
elif part == '':
pass
elif part == '...':
cwd = os.path.dirname(cwd)
cwd = os.path.dirname(cwd)
else:
cwd = os.path.join(cwd, part)
return cwd
if not path or path[0] == '/':
return path
else:
parts = path.split('/')
for p in parts:
cwd = cd(cwd, p)
return cwd
def fast_pcs_server(j):
if 'fs' not in args.type_:
return j
do = lambda dlink: \
re.sub(r'://[^/]+?/', '://c.pcs.baidu.com/', dlink)
#re.sub(r'://[^/]+?/', '://c.pcs.baidu.com/', dlink)
if isinstance(j, dict) and j.get('info') and len(j['info']) > 0:
for i in xrange(len(j['info'])):
if j['info'][i].get('dlink'):
j['info'][i]['dlink'] = do(j['info'][i]['dlink'])
else:
j = do(j)
return j
def is_wenxintishi(dlink):
while True:
try:
res = ss.head(dlink)
break
except requests.exceptions.ConnectionError:
time.sleep(2)
location = res.headers.get('location', '')
if 'wenxintishi' in location:
return True
else:
return False
# https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
def sizeof_fmt(num):
for x in ['B','KB','MB','GB']:
if num < 1024.0:
return "%3.1f%s" % (num, x)
num /= 1024.0
return "%3.1f%s" % (num, 'TB')
def print_process_bar(point, total, slice_size,
start_time=None, pre='', suf='', msg=''):
length = 20
nowpoint = point / (total + 0.0)
percent = round(100 * nowpoint, 1)
now = time.time()
speed = sizeof_fmt(slice_size / (now - start_time)) + '/s'
t = int(nowpoint*length)
msg = '\r' + ' '.join([pre, '|%s%s|' % ('='*t, ' '*(length - t)), \
str(percent) + '%', speed, msg, suf])
sys.stdout.write(msg)
sys.stdout.flush()
return now
def is_cookie(cookie):
return 'BDUSS=' in cookie and 'PANPSC=' in cookie and len(cookie) > 150
def parse_cookies(cookie):
cookies = {}
for c in cookie.split('; '):
k, v = c.split('=', 1)
cookies[k] = v
return cookies
class panbaiducom_HOME(object):
def __init__(self):
self._download_do = self._play_do if args.play else self._download_do
self.ondup = 'overwrite'
self.accounts = self._check_cookie_file()
self.dsign = None
self.timestamp = None
self.user_id = None
self.highlights = []
if any([args.tails, args.heads, args.includes]):
for tail in args.tails:
self.highlights.append({'text': tail.decode('utf8', 'ignore'),
'is_regex': 0})
for head in args.heads:
self.highlights.append({'text': head.decode('utf8', 'ignore'),
'is_regex': 0})
for include in args.includes:
self.highlights.append({'text': include.decode('utf8', 'ignore'),
'is_regex': 1})
if 'ec' in args.type_ or 'dc' in args.type_ or args.comd == 'dc':
import_shadowsocks()
def _request(self, method, url, action, **kwargs):
i = 0
while i < 3:
i += 1
response = ss.request(method, url, **kwargs)
if not (response.ok is True and response.status_code == 200):
continue
else:
return response
self.save_cookies()
print s % (1, 91, ' ! [{}] Server error'.format(action))
sys.exit()
@staticmethod
def _check_cookie_file():
def correct_do():
with open(cookie_file, 'wb') as g:
pk.dump({}, g)
print s % (1, 97, ' please login')
return
if not os.path.exists(cookie_file):
correct_do()
return {}
try:
j = pk.load(open(cookie_file))
except:
correct_do()
return {}
if type(j) != type({}):
correct_do()
return {}
for i in j:
if type(j[i]) != type({}):
del j[i]
else:
if not j[i].get('cookies'):
del j[i]
return j
def init(self):
if self.accounts:
j = self.accounts
u = [u for u in j if j[u]['on']]
if u:
user = u[0]
self.user = user
self.cwd = j[user]['cwd'] if j[user].get('cwd') else '/'
self.user_id = j[user].get('user_id')
self.bduss = j[user]['cookies']['BDUSS']
ss.cookies.update(j[user]['cookies'])
else:
print s % (1, 91, ' !! no account is online, please login or userchange')
sys.exit(1)
if not self.check_login():
print s % (1, 91, ' !! cookie is invalid, please login.'), u[0]
del j[u[0]]
with open(cookie_file, 'w') as g:
pk.dump(j, g)
sys.exit(1)
if not self.user_id:
info = self._user_info(self.bduss)
self.user_id = info['user']['id']
else:
print s % (1, 97, ' no account, please login')
sys.exit(1)
@staticmethod
def save_img(url, ext):
path = os.path.join(os.path.expanduser('~'), 'vcode.%s' % ext)
with open(path, 'w') as g:
res = ss.get(url)
data = res.content
g.write(data)
print " ++ 验证码已保存至", s % (1, 97, path)
input_code = raw_input(s % (2, 92, " 输入验证码: "))
return input_code
def check_login(self):
# html_string = self._request('GET', 'http://pan.baidu.com/', 'check_login').content
info = self._meta(['/'])
if info and info['errno'] == 0:
return True
else:
print s % (1, 91, ' -- check_login fail\n')
return False
#print s % (1, 92, ' -- check_login success\n')
#self.get_dsign()
#self.save_cookies()
def login(self, username, password):
print s % (1, 97, '\n -- login')
if is_cookie(password):
cookies = parse_cookies(password)
ss.cookies.update(cookies)
return
# error_message: at _check_account_exception from
# https://github.com/ly0/baidupcsapi/blob/master/baidupcsapi/api.py
login_error_msg = {
'-1': '系统错误, 请稍后重试',
'1': '输入的帐号格式不正确',
'3': '验证码不存在或已过期,请重新输入',
'4': '输入的帐号或密码有误',
'5': '请重新登录',
'6': '验证码输入错误',
'16': '帐号因安全问题已被限制登录',
'257': '需要验证码',
'100005': '系统错误, 请稍后重试',
'120016': '未知错误 120016',
'120019': '近期登录次数过多, 请先通过 passport.baidu.com 解除锁定',
'120021': '登录失败,重新登录',
'500010': '登录过于频繁,请24小时后再试',
'400031': '账号异常',
'401007': '手机号关联了其他帐号,请选择登录'
}
self._request('GET', 'http://www.baidu.com', 'login')
# Get token
# token = self._get_bdstoken()
resp = self._request('GET', 'https://passport.baidu.com/v2/api/?getapi&tpl=netdisk'
'&apiver=v3&tt={}&class=login&logintype=basicLogin'.format(int(time.time())),
'login')
_json = json.loads(resp.content.replace('\'', '"'))
if _json['errInfo']['no'] != "0":
print s % (1, 91, ' ! Can\'t get token')
sys.exit(1)
token = _json['data']['token']
code_string = _json['data']['codeString']
# get publickey
# url = ('https://passport.baidu.com/v2/getpublickey?&token={}'
# '&tpl=netdisk&apiver=v3&tt={}').format(token, int(time.time()))
# r = ss.get(url)
# j = json.loads(r.content.replace('\'', '"'))
# pubkey = j['pubkey']
# key = rsa.PublicKey.load_pkcs1_openssl_pem(pubkey)
# password_encoded = base64.b64encode(rsa.encrypt(password, key))
# rsakey = j['key']
# Construct post body
verifycode = ''
while True:
data = {
"staticpage": "http://pan.baidu.com/res/static/thirdparty/pass_v3_jump.html",
"charset": "utf-8",
"token": token,
"tpl": "netdisk",
"subpro": "",
"apiver": "v3",
"tt": int(time.time()),
"codestring": code_string,
"safeflg": "0",
"u": "http://pan.baidu.com/",
"isPhone": "",
"quick_user": "0",
"logintype": "basicLogin",
"logLoginType": "pc_loginBasic",
"idc": "",
"loginmerge": "true",
"username": username,
"password": password,
"verifycode": verifycode,
"mem_pass": "on",
"rsakey": "",
"crypttype": "",
"ppui_logintime": "2602",
"callback": "parent.bd__pcbs__ahhlgk",
}
# Post!
# XXX : do not handle errors
url = 'https://passport.baidu.com/v2/api/?login'
r = ss.post(url, data=data)
# Callback for verify code if we need
#code_string = r.content[r.content.index('(')+1:r.content.index(')')]
errno = re.search(r'err_no=(\d+)', r.content).group(1)
if ss.cookies.get('BDUSS'):
# ss.get("http://pan.baidu.com/disk/home")
break
elif errno in ('257', '3', '6'):
print s % (1, 91, ' ! Error %s:' % errno), \
login_error_msg[errno]
t = re.search('codeString=(.+?)&', r.content)
code_string = t.group(1) if t else ""
vcurl = 'https://passport.baidu.com/cgi-bin/genimage?' + code_string
verifycode = self.save_img(vcurl, 'jpg') if code_string != "" else ""
data['codestring'] = code_string
data['verifycode'] = verifycode
#self.save_cookies()
else:
print s % (1, 91, ' ! Error %s:' % errno), \
login_error_msg.get(errno, "unknow, please feedback to author")
sys.exit(1)
def save_cookies(self, username=None, on=0, tocwd=False):
if not username: username = self.user
accounts = self.accounts
accounts[username] = accounts.get(username, {})
accounts[username]['cookies'] = \
accounts[username].get('cookies', ss.cookies.get_dict())
accounts[username]['on'] = on
accounts[username]['user_id'] = self.user_id
quota = self._get_quota()
capacity = '%s/%s' % (sizeof_fmt(quota['used']), sizeof_fmt(quota['total']))
accounts[username]['capacity'] = capacity
if hasattr(self, 'cwd'):
if not accounts[username].get('cwd'):
accounts[username]['cwd'] = '/'
if tocwd: accounts[username]['cwd'] = self.cwd
else:
accounts[username]['cwd'] = '/'
for u in accounts:
if u != username and on:
accounts[u]['on'] = 0
with open(cookie_file, 'w') as g:
pk.dump(accounts, g)
def _get_bdstoken(self):
if hasattr(self, 'bdstoken'):
return self.bdstoken
resp = self._request('GET', 'http://pan.baidu.com/disk/home',
'_get_bdstoken')
html_string = resp.content
mod = re.search(r'bdstoken[\'":\s]+([0-9a-f]{32})', html_string)
if mod:
self.bdstoken = mod.group(1)
return self.bdstoken
else:
print s % (1, 91, ' ! Can\'t get bdstoken')
sys.exit(1)
# self.bdstoken = md5.new(str(time.time())).hexdigest()
def _user_info(self, bduss):
timestamp = str(int(time.time()))
model = get_phone_model(bduss)
phoneIMEIStr = sum_IMEI(bduss)
data = {
'bdusstoken': bduss + '|null',
'channel_id': '',
'channel_uid': '',
'stErrorNums': '0',
'subapp_type': 'mini',
'timestamp': timestamp + '922',
}
data['_client_type'] = '2'
data['_client_version'] = '7.0.0.0'
data['_phone_imei'] = phoneIMEIStr
data['from'] = 'mini_ad_wandoujia'
data['model'] = model
data['cuid'] = to_md5(
bduss + '_' + data['_client_version'] + '_' + data['_phone_imei'] + '_' + data['from']
).upper() + '|' + phoneIMEIStr[::-1]
data['sign'] = to_md5(
''.join([k + '=' + data[k] for k in sorted(data.keys())]) + 'tiebaclient!!!'
).upper()
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': 'ka=open',
'net': '1',
'User-Agent': 'bdtb for Android 6.9.2.1',
'client_logid': timestamp + '416',
'Connection': 'Keep-Alive',
}
resp = requests.post('http://tieba.baidu.com/c/s/login', headers=headers, data=data)
info = resp.json()
return info
#def _sift(self, fileslist, name=None, size=None, time=None, head=None, tail=None, include=None, exclude=None):
def _sift(self, fileslist, **arguments):
"""
a filter for time, size, name, head, tail, include, exclude, shuffle
support regular expression
"""
# for shuffle
if 's' in args.type_:
random.shuffle(fileslist)
return fileslist
# for time
elif arguments.get('name'):
reverse = None
if arguments['name'] == 'reverse':
reverse = True
elif arguments['name'] == 'no_reverse':
reverse = False
fileslist = sorted(fileslist, key=lambda k: k['server_filename'],
reverse=reverse)
# for size
elif arguments.get('size'):
reverse = None
if arguments['size'] == 'reverse':
reverse = True
elif arguments['size'] == 'no_reverse':
reverse = False
fileslist = sorted(fileslist, key=lambda k: k['size'],
reverse=reverse)
# for time
elif arguments.get('time'):
reverse = None
if arguments['time'] == 'reverse':
reverse = True
elif arguments['time'] == 'no_reverse':
reverse = False
fileslist = sorted(fileslist, key=lambda k: k['server_mtime'],
reverse=reverse)
# for head, tail, include, exclude
heads = args.heads
tails = args.tails
includes = args.includes
excludes = args.excludes
keys1, keys2, keys3, keys4 = [], [], [], []
if heads or tails or includes or excludes:
tdict = {
fileslist[i]['server_filename'] : i for i in xrange(len(fileslist))
}
for head in heads:
keys1 += [
i for i in tdict.keys()
if i.lower().startswith(
head.decode('utf8', 'ignore').lower()
)
]
for tail in tails:
keys2 += [
i for i in tdict.keys()
if i.lower().endswith(
tail.decode('utf8', 'ignore').lower()
)
]
for include in includes:
keys3 += [
i for i in tdict.keys()
if re.search(
include.decode('utf8', 'ignore'), i, flags=re.I
)
]
for exclude in excludes:
keys4 += [
i for i in tdict.keys()
if not re.search(