├── .gitignore ├── .idea ├── .name ├── artifacts │ └── CloudMusicToYunPan_jar.xml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── libraries │ ├── CloudMusic.xml │ └── YunOffline.xml ├── misc.xml ├── modules.xml ├── uiDesigner.xml └── workspace.xml ├── CloudMusicToYunPan.iml ├── CloudMusicToYunPan.jar ├── README.md ├── cookie.file ├── logintoken.properties ├── out └── production │ └── CloudMusicToYunPan │ ├── META-INF │ └── MANIFEST.MF │ └── com │ └── fireawayh │ └── main │ └── cloudmusictoyunpan │ └── CloudMusicToYunPan.class ├── pantoken.txt ├── src ├── META-INF │ └── MANIFEST.MF └── com │ └── fireawayh │ └── main │ └── cloudmusictoyunpan │ └── CloudMusicToYunPan.java ├── token.txt └── userinfo.properties /.gitignore: -------------------------------------------------------------------------------- 1 | cookie.file 2 | *.txt 3 | *.properties -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | CloudMusicToYunPan -------------------------------------------------------------------------------- /.idea/artifacts/CloudMusicToYunPan_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$ 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/libraries/CloudMusic.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/libraries/YunOffline.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 29 | 30 | 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 | 86 | 87 | 88 | 93 | 95 | 96 | 103 | 106 | 107 | 108 | 128 | 129 | 130 | 131 | 132 | true 133 | 134 | 135 | 140 | 141 | 142 | 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 | 177 | 178 | 181 | 182 | 185 | 186 | 189 | 190 | 191 | 192 | 195 | 196 | 199 | 200 | 203 | 204 | 207 | 208 | 211 | 212 | 213 | 214 | 217 | 218 | 221 | 222 | 225 | 226 | 229 | 230 | 233 | 234 | 237 | 238 | 241 | 242 | 243 | 244 | 247 | 248 | 251 | 252 | 255 | 256 | 259 | 260 | 263 | 264 | 267 | 268 | 271 | 272 | 273 | 274 | 277 | 278 | 281 | 282 | 285 | 286 | 289 | 290 | 291 | 292 | 295 | 296 | 299 | 300 | 303 | 304 | 307 | 308 | 311 | 312 | 313 | 314 | 317 | 318 | 321 | 322 | 325 | 326 | 329 | 330 | 333 | 334 | 337 | 338 | 341 | 342 | 343 | 344 | 347 | 348 | 351 | 352 | 355 | 356 | 359 | 360 | 363 | 364 | 367 | 368 | 371 | 372 | 373 | 374 | 377 | 378 | 381 | 382 | 383 | 384 | 387 | 388 | 391 | 392 | 393 | 394 | 397 | 398 | 401 | 402 | 405 | 406 | 407 | 408 | 411 | 412 | 415 | 416 | 419 | 420 | 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 | 455 | 456 | 469 | 470 | 471 | 472 | 475 | 476 | 489 | 490 | 491 | 495 | 496 | 503 | 504 | 505 | 518 | 519 | 520 | 521 | 526 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 552 | 570 | 577 | 578 | 579 | 596 | 597 | 618 | 631 | 632 | 641 | 645 | 646 | 647 | 654 | 657 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 734 | 735 | 736 | 737 | 738 | 739 | 750 | 751 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 785 | 792 | 793 | 794 | 795 | 813 | 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 | 1453054511831 872 | 882 | 883 | 1453863072514 884 | 888 | 889 | 1453915654377 890 | 894 | 895 | 1453915673543 896 | 900 | 901 | 1453915795388 902 | 906 | 907 | 1453916344386 908 | 912 | 913 | 1453916393639 914 | 918 | 919 | 1453917236504 920 | 924 | 925 | 1454454751794 926 | 930 | 931 | 1457539719465 932 | 936 | 937 | 1457540039536 938 | 942 | 943 | 1457541571073 944 | 948 | 951 | 952 | 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 | 986 | 987 | 990 | 993 | 994 | 995 | 997 | 998 | 1008 | 1009 | 1010 | 1011 | 1012 | jar://$PROJECT_DIR$/../CloudMusic/out/artifacts/CloudMusic_jar/CloudMusic.jar!/com/fireawayh/cloudmusic/utils/MusicUtils.class 1013 | 23 1014 | 1015 | 1017 | 1018 | file://$PROJECT_DIR$/src/com/fireawayh/main/cloudmusictoyunpan/CloudMusicToYunPan.java 1019 | 182 1020 | 1021 | 1023 | 1024 | file://$PROJECT_DIR$/../YunOffline/src/com/fireawayh/main/YunOffline.java 1025 | 118 1026 | 1027 | 1029 | 1030 | 1032 | 1033 | 1034 | 1035 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1127 | 1128 | 1129 | 1130 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | 1201 | 1202 | 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1260 | 1261 | 1262 | 1263 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1325 | 1326 | 1327 | 1328 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | 1341 | 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | 1350 | 1351 | 1352 | 1353 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | 1372 | 1373 | 1374 | 1375 | 1376 | 1377 | 1378 | 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1389 | 1390 | 1391 | 1392 | 1393 | 1394 | 1395 | 1396 | 1397 | 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | 1407 | 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | 1415 | 1416 | 1417 | 1418 | 1419 | 1420 | 1421 | 1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | 1430 | 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1448 | 1449 | 1450 | 1451 | 1452 | 1453 | 1454 | 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | 1470 | 1471 | 1472 | 1473 | 1474 | CloudMusicToYunPan:jar 1475 | 1476 | 1482 | 1483 | 1484 | 1485 | 1486 | 1487 | No facets are configured 1488 | 1489 | 1494 | 1495 | 1496 | 1497 | 1498 | 1499 | 1500 | 1505 | 1506 | 1507 | 1508 | 1509 | 1510 | 1.8 1511 | 1512 | 1517 | 1518 | 1519 | 1520 | 1521 | 1522 | CloudMusicToYunPan 1523 | 1524 | 1530 | 1531 | 1532 | 1533 | 1534 | 1535 | 1.7 1536 | 1537 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | CloudMusic 1548 | 1549 | 1554 | 1555 | 1556 | 1557 | 1558 | 1559 | -------------------------------------------------------------------------------- /CloudMusicToYunPan.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /CloudMusicToYunPan.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hejiheji001/CloudMusicToYunPan/83fe8ee3dfe0de0a60de2c7a4e9fe778d2364279/CloudMusicToYunPan.jar -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CloudMusicToYunPan 2 | 3 | Sometimes you need to enter the verify code, you need to install jp2a and ImageMagick 4 | 5 | if you want to see the ascii version directly in your terminal 6 | 7 | > Mac OS X 8 | 9 | >> port or brew install jp2a 10 | 11 | >> port or brew install ImageMagick 12 | 13 | > FreeBSD 14 | 15 | >> pkg_add -r jp2a 16 | 17 | > Debian 18 | 19 | > >apt-get install jp2a 20 | 21 | > Gentoo 22 | 23 | >> emerge jp2a 24 | 25 | >>> See: https://csl.name/jp2a/ 26 | 27 | >>> See: http://www.imagemagick.org/script/binary-releases.php 28 | 29 | # Useage: 30 | 31 | ## Support GUI now! Simply double click the jar file or java -jar xxx.jar 32 | 33 | ## Or you can still run it in command line 34 | ###java -jar xxx.jar -u [your baidu username] -p [your baidu password] [options] 35 | ###java -jar xxx.jar -conf [userinfo.properties] [options] 36 | 37 | # Options 38 | ### -r rename.txt 39 | #### rename downloaded tasks automatically according to the given txt file (based on path and file name) 40 | >PS1: rename.txt will generated by this tool when you add some tasks. 41 | 42 | >PS2: you can change the name of any file you like, just edit the txt file, specify the right path, old name and new name 43 | 44 | ### -id [netease music id] 45 | #### add a song with this id as an offline task to your baidu yun, 320K prefered 46 | #### example1: http://music.163.com/m/song/29572501 47 | #### example2: http://music.163.com/song?id=29572501 48 | 49 | ### -playlist [netease playlist id] 50 | #### add some songs belong to this playlist as offline tasks to your baidu yun, 320K prefered 51 | #### example1: http://music.163.com/m/playlist?id=41370921 52 | #### example2: http://music.163.com/#/playlist?id=41370921 53 | 54 | ### -path [save path of your baidu yun] 55 | #### default value is / 56 | >PS: new folder will be created if does not exists 57 | -------------------------------------------------------------------------------- /cookie.file: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hejiheji001/CloudMusicToYunPan/83fe8ee3dfe0de0a60de2c7a4e9fe778d2364279/cookie.file -------------------------------------------------------------------------------- /logintoken.properties: -------------------------------------------------------------------------------- 1 | logintoken=2e885cea0945237461145f9d69447fd2 -------------------------------------------------------------------------------- /out/production/CloudMusicToYunPan/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.fireawayh.main.cloudmusictoyunpan.CloudMusicToYunPan 3 | 4 | -------------------------------------------------------------------------------- /out/production/CloudMusicToYunPan/com/fireawayh/main/cloudmusictoyunpan/CloudMusicToYunPan.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hejiheji001/CloudMusicToYunPan/83fe8ee3dfe0de0a60de2c7a4e9fe778d2364279/out/production/CloudMusicToYunPan/com/fireawayh/main/cloudmusictoyunpan/CloudMusicToYunPan.class -------------------------------------------------------------------------------- /pantoken.txt: -------------------------------------------------------------------------------- 1 | a7142a293a25a0fca77738e569d4a300 -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: com.fireawayh.main.cloudmusictoyunpan.CloudMusicToYunPan 3 | 4 | -------------------------------------------------------------------------------- /src/com/fireawayh/main/cloudmusictoyunpan/CloudMusicToYunPan.java: -------------------------------------------------------------------------------- 1 | package com.fireawayh.main.cloudmusictoyunpan; 2 | 3 | import com.fireawayh.cloudmusic.utils.ApiUtils; 4 | import com.fireawayh.cloudmusic.utils.JsonUtils; 5 | import com.fireawayh.cloudmusic.utils.MusicUtils; 6 | import com.fireawayh.main.YunOffline; 7 | import com.fireawayh.util.IOUtils; 8 | import com.fireawayh.util.ShowGUI; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.awt.event.*; 13 | import java.io.File; 14 | import java.io.FileInputStream; 15 | import java.util.*; 16 | import java.util.List; 17 | import java.util.regex.Matcher; 18 | import java.util.regex.Pattern; 19 | 20 | /** 21 | * By FireAwayH on 17/01/2016. 22 | */ 23 | public class CloudMusicToYunPan { 24 | // private static DownloadUtils du = new DownloadUtils(); 25 | private static JsonUtils ju = new JsonUtils(); 26 | private static ApiUtils au = new ApiUtils(); 27 | private static IOUtils iou = new IOUtils(); 28 | 29 | 30 | public static void main(String[] args){ 31 | List argList = Arrays.asList(args); 32 | 33 | if(argList.isEmpty()){ 34 | // test(); 35 | showGUI(); 36 | } 37 | 38 | String username = ""; 39 | String password = ""; 40 | String path = "/"; 41 | 42 | if(argList.contains("-u") && argList.contains("-p")) { 43 | username = argList.get(argList.indexOf("-u") + 1); 44 | password = argList.get(argList.indexOf("-p") + 1); 45 | } 46 | 47 | if(argList.contains("-conf")){ 48 | try { 49 | String filename = argList.get(argList.indexOf("-conf") + 1); 50 | // filename = "userinfo.properties"; 51 | Properties prop = new Properties(); 52 | File file = new File(filename); 53 | if (file.exists()) { 54 | prop.load(new FileInputStream(file)); 55 | username = prop.getProperty("Username"); 56 | password = prop.getProperty("Password"); 57 | path = prop.getProperty("Savepath"); 58 | } 59 | } catch (Exception e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | 64 | if(!username.isEmpty() && !password.isEmpty()){ 65 | init(username, password, argList, path); 66 | } 67 | } 68 | 69 | private static void showGUI() { 70 | TextField idText = new TextField(); 71 | Frame frame = new Frame("Cloud Music Downloader"); 72 | Dialog dialog = new Dialog(frame, "Hint", true); 73 | idText.setColumns(15); 74 | DefaultComboBoxModel typeSelector = new DefaultComboBoxModel<>(); 75 | typeSelector.addElement("Music ID"); 76 | typeSelector.addElement("Playlist ID"); 77 | typeSelector.addElement("Rename By File"); 78 | JComboBox idType = new JComboBox<>(typeSelector); 79 | Button start = new Button("Start!"); 80 | frame.add(idType); 81 | frame.add(idText); 82 | frame.add(start); 83 | frame.setLayout(new FlowLayout()); 84 | frame.setSize(250, 100); 85 | frame.setResizable(false); 86 | frame.setLocation(getCenter(frame)); 87 | frame.setVisible(true); 88 | frame.addWindowListener( 89 | new WindowAdapter() { 90 | public void windowClosing(WindowEvent e) { 91 | System.exit(0); 92 | } 93 | } 94 | ); 95 | 96 | idType.addItemListener( 97 | new ItemListener() { 98 | public void itemStateChanged(ItemEvent event) { 99 | switch (event.getStateChange()) { 100 | case ItemEvent.SELECTED: 101 | if (event.getItem().equals("Rename By File")) { 102 | idText.setText("rename.txt"); 103 | } else { 104 | idText.setText(""); 105 | } 106 | break; 107 | } 108 | } 109 | } 110 | ); 111 | 112 | start.addMouseListener( 113 | new MouseAdapter() { 114 | @Override 115 | public void mouseClicked(MouseEvent e) { 116 | Label l = new Label(); 117 | l.setAlignment(Label.CENTER); 118 | dialog.setSize(150, 50); 119 | dialog.setLocation(getCenter(dialog)); 120 | dialog.addWindowListener( 121 | new WindowAdapter() { 122 | @Override 123 | public void windowClosing(WindowEvent e) { 124 | dialog.removeAll(); 125 | dialog.dispose(); 126 | } 127 | } 128 | ); 129 | String songId = idText.getText(); 130 | 131 | if (songId.isEmpty()) { 132 | l.setText("Music id or Playlist id is required"); 133 | dialog.add(l); 134 | dialog.setVisible(true); 135 | return; 136 | } 137 | 138 | start.setLabel("Working"); 139 | start.setEnabled(false); 140 | 141 | new Thread(new Runnable() { 142 | @Override 143 | public void run() { 144 | ShowGUI s = new ShowGUI(); 145 | 146 | if (idType.getSelectedItem().equals("Music ID")) { 147 | String[] durl = getDURLById(songId); 148 | s.showGui(durl); 149 | } 150 | if (idType.getSelectedItem().equals("Playlist ID")) { 151 | ArrayList songIds = ju.getPlayListSongs(songId); 152 | ArrayList durls = new ArrayList<>(); 153 | for (int i = 0; i < songIds.size() - 1; i++) { 154 | String[] durl = getDURLById(songIds.get(i)); 155 | durls.add(durl); 156 | } 157 | s.showGui(durls); 158 | } 159 | if (idType.getSelectedItem().equals("Rename By File")) { 160 | s.showGui(songId); 161 | } 162 | 163 | start.setLabel("Start"); 164 | start.setEnabled(true); 165 | } 166 | }).start(); 167 | } 168 | } 169 | ); 170 | } 171 | 172 | private static Point getCenter(Window f) { 173 | int windowWidth = f.getWidth(); //获得窗口宽 174 | int windowHeight = f.getHeight(); 175 | Toolkit kit = Toolkit.getDefaultToolkit(); //定义工具包 176 | Dimension screenSize = kit.getScreenSize(); //获取屏幕的尺寸 177 | int screenWidth = screenSize.width; //获取屏幕的宽 178 | int screenHeight = screenSize.height; 179 | return new Point(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2); 180 | } 181 | 182 | public static void init(String username, String password, List argList, String path) { 183 | YunOffline yo = new YunOffline(username, password); 184 | if (yo.initYunPan()) { 185 | yo.getYunPanToken(); 186 | if (argList.contains("-r")) { 187 | String filename = argList.get(argList.indexOf("-r") + 1).toUpperCase(); 188 | rename(yo, filename); 189 | } 190 | 191 | if (argList.contains("-path")) { 192 | path = argList.get(argList.indexOf("-path") + 1).toUpperCase(); 193 | } 194 | 195 | if (argList.contains("-playlist")) { 196 | String playListId = argList.get(argList.indexOf("-playlist") + 1).toUpperCase(); 197 | System.out.println("Saved Playlist " + playListId + " To Yun Pan"); 198 | saveListToYunPan(yo, playListId, path); 199 | } 200 | if (argList.contains("-id")) { 201 | String songId = argList.get(argList.indexOf("-id") + 1).toUpperCase(); 202 | System.out.println("Saved Song " + songId + " To Yun Pan"); 203 | saveToYunPan(yo, songId, path); 204 | } 205 | } else { 206 | System.err.println("Init Failed"); 207 | } 208 | } 209 | 210 | public static void rename(YunOffline yo, String filename){ 211 | String[] content = iou.getStringFromFile(filename).split("Item:"); 212 | for(String c : content){ 213 | if(!c.isEmpty()) { 214 | String[] info = c.split(","); 215 | String path = info[0].split("=")[1]; 216 | String oldName = info[1].split("=")[1]; 217 | String newName = info[2].split("=")[1]; 218 | yo.renameFile(path, oldName, newName); 219 | } 220 | } 221 | } 222 | 223 | public static void saveToYunPan(YunOffline yo, String id, String path){ 224 | MusicUtils mu = new MusicUtils(id); 225 | Map music = mu.getBestMusic().object(); 226 | String artistName = mu.getArtist(); 227 | String songName = mu.getSongName(); 228 | String bestMusicId = music.get("dfsId").toString(); 229 | String fileName = artistName + " - " + songName + "." + music.get("extension"); 230 | // String newFileName = stringConvert(fileName); 231 | String durl = au.getDownloadUrl(bestMusicId); 232 | Pattern p = Pattern.compile("/([0-9]*.mp3)"); 233 | Matcher matcher = p.matcher(durl); 234 | String oldFileName = ""; 235 | if (matcher.find()) { 236 | oldFileName = matcher.group(1); 237 | } 238 | 239 | System.out.println("Current task: " + fileName); 240 | yo.setSource_url(durl); 241 | yo.setSavepath(path); 242 | yo.saveToYunPan("", ""); 243 | iou.appendStringToFile("Item:path=" + path + ",old=" + oldFileName + ",new=" + fileName + "\r\n", "rename.txt"); 244 | // if(!taskid.isEmpty()){ 245 | // System.out.println("Saved TO Yun Pan, ID IS " + taskid); 246 | // }else{ 247 | // System.out.println("Failed To Save To Yun Pan"); 248 | // } 249 | } 250 | 251 | public static void saveListToYunPan(YunOffline yo, String listId, String path){ 252 | ArrayList songIds = ju.getPlayListSongs(listId); 253 | for (int i = 0; i < songIds.size() - 1; i++){ 254 | saveToYunPan(yo, songIds.get(i), path); 255 | } 256 | } 257 | 258 | // public static String stringConvert(String str) { 259 | // try { 260 | // String fileEncode = System.getProperty("file.encoding"); 261 | // return new String(str.getBytes("UTF-8"), fileEncode); 262 | // }catch (Exception e){ 263 | // return "?"; 264 | // } 265 | // } 266 | 267 | public static String[] getDURLById(String id) { 268 | MusicUtils mu = new MusicUtils(id); 269 | Map music = mu.getBestMusic().object(); 270 | String artistName = mu.getArtist(); 271 | String ext = music.get("extension").toString(); 272 | String songName = mu.getSongName(); 273 | String bestMusicId = music.get("dfsId").toString(); 274 | 275 | String newName = artistName + " - " + songName + "." + ext; 276 | return new String[]{au.getDownloadUrl(bestMusicId), "", bestMusicId + ext, newName}; 277 | } 278 | 279 | public static void test(){ 280 | // YunOffline yo = new YunOffline("hejiheji001@163.com", "MyLifeForFire0"); 281 | ////// yo.setPanToken("ee7f2c5c90a95e5c4ac6425f21a994d1"); 282 | // if(yo.initYunPan()) { 283 | // yo.getYunPanToken(); 284 | //// saveListToYunPan(yo, "41370921"); 285 | // rename(yo, "rename.txt"); 286 | // } 287 | // 288 | System.out.println("-u -p [options]"); 289 | System.out.println("-c [options]"); 290 | System.out.println("-u -p [options]"); 291 | System.out.println("-path "); 292 | System.out.println("-id "); 293 | System.out.println("or"); 294 | System.out.println("-playlist "); 295 | 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /token.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hejiheji001/CloudMusicToYunPan/83fe8ee3dfe0de0a60de2c7a4e9fe778d2364279/token.txt -------------------------------------------------------------------------------- /userinfo.properties: -------------------------------------------------------------------------------- 1 | Username=hejiheji001@163.com 2 | Password=MyLifeForFire0 3 | Savepath=/ --------------------------------------------------------------------------------