File tree 2 files changed +28
-4
lines changed
2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 1
- # monstercat-dl
1
+ # : musical_note : monstercat-dl
2
2
3
3
Download Monstercat songs from your Terminal app!
4
4
@@ -8,6 +8,8 @@ To get monstercat-dl working correctly, you will need this:
8
8
- [ wget] ( https://www.gnu.org/software/wget/ ) (on macOS ` brew install wget ` )
9
9
- [ php] ( https://php.net ) >= 7.0
10
10
11
+ :warning : If you don't want to use ` wget ` and prefer ` php ` native functions, use ` --without-get ` argument.
12
+
11
13
## Usage
12
14
13
15
First, browse [ monstercat.com] ( https://www.monstercat.com ) and find the release you wish to download.
@@ -20,12 +22,12 @@ We just need the release ID, in this case: `MCEP157`.
20
22
Download all songs in this release with this simple command:
21
23
22
24
``` bash
23
- php monstercat-dl.php MCEP157
25
+ php monstercat-dl.phar MCEP157
24
26
```
25
27
26
28
You can download more songs at once by adding other release IDs at the end of the command:
27
29
``` bash
28
- php monstercat-dl.php MCEP157 MCX006 MCS778
30
+ php monstercat-dl.phar MCEP157 MCX006 MCS778
29
31
```
30
32
31
33
All songs will be downloaded in your current directory, you can ` cd ` into another one.
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ function getAlbum(string $key): Array
51
51
function ($ key ) { return is_numeric ($ key ); },
52
52
ARRAY_FILTER_USE_KEY
53
53
);
54
+ $ blobs = [];
54
55
55
56
foreach ($ releases as $ key => $ releaseID ) {
56
57
$ release = new Release ($ releaseID );
@@ -63,8 +64,29 @@ function ($key) { return is_numeric($key); },
63
64
64
65
if ($ album ->getStatus () === 200 ) {
65
66
foreach ($ album ->getMusics () as $ music ) {
66
- exec ("wget " . $ music ->getDownloadLink () . " -O \"" . $ music ->getFileName () . ".mp3 \"" );
67
+ $ blobs [$ music ->getFileName ()] = $ music ->getDownloadLink ();
68
+ echo ' - ' . $ music ->getFileName () . PHP_EOL ;
67
69
}
68
70
}
69
71
}
72
+
73
+ echo PHP_EOL ;
74
+ }
75
+
76
+ foreach ($ blobs as $ name => $ url ) {
77
+ if (isset ($ args ['without-wget ' ])) {
78
+ echo "[Downloading] ` $ name`... " ;
79
+ if (
80
+ file_put_contents (
81
+ $ name . '.mp3 ' ,
82
+ file_get_contents ($ url )
83
+ )
84
+ ) {
85
+ echo 'Ok ' . PHP_EOL ;
86
+ } else {
87
+ echo 'FAILED ' . PHP_EOL ;
88
+ }
89
+ } else {
90
+ exec ("wget $ url -O \"$ name.mp3 \"" );
91
+ }
70
92
}
You can’t perform that action at this time.
0 commit comments