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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
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
|
%global _empty_manifest_terminate_build 0
Name: python-ytmdl
Version: 2023.2.28
Release: 1
Summary: Youtube Music Downloader
License: MIT License
URL: https://github.com/deepjyoti30/ytmdl
Source0: https://mirrors.aliyun.com/pypi/web/packages/ef/99/a7de28eb06797d63126c5655590998d1389adf81547e4a876e678d1904f7/ytmdl-2023.2.28.tar.gz
BuildArch: noarch
Requires: python3-yt-dlp
Requires: python3-mutagen
Requires: python3-itunespy
Requires: python3-requests
Requires: python3-colorama
Requires: python3-beautifulsoup4
Requires: python3-downloader-cli
Requires: python3-pyxdg
Requires: python3-ffmpeg-python
Requires: python3-pysocks
Requires: python3-unidecode
Requires: python3-youtube-search-python
Requires: python3-pyDes
Requires: python3-urllib3
Requires: python3-simber
Requires: python3-rich
Requires: python3-musicbrainzngs
Requires: python3-ytmusicapi
Requires: python3-spotipy
Requires: python3-inaSpeechSegmenter
Requires: python3-tensorflow
%description
<div align="center">
<img src=".github/ytmdl.png">
</div>
<div align="center">
<h1>YouTube Music Downloader</h1>
<h4>Download songs from YouTube by getting the audio from YouTube and the metadata from sources like Itunes, Spotify, Gaana etc.</h4>
</div>
<div align="center" width="60%" height="auto">
<br>
<img src=".github/ytmdl.gif">
</div>
<div align="center">
<br/>
[](https://www.python.org/)<br/><br/>
<img src="https://img.shields.io/badge/Maintained%3F-Yes-blueviolet?style=for-the-badge">
 ](https://apis.deepjyoti30.dev/repostatus/badge?repo=deepjyoti30%2Fytmdl&style=for-the-badge) [](LICENSE.md)   [](https://img.shields.io/badge/dynamic/json?style=for-the-badge&maxAge=86400&label=downloads&query=%24.total_downloads&url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2Fytmdl) [](http://makeapullrequest.com) [](https://t.me/ytmdl)
<p>
<a href="https://ko-fi.com/deepjyoti30"><img src="https://raw.githubusercontent.com/adi1090x/files/master/other/kofi.png" alt="Support me on ko-fi"></a>
</p>
<br/>
### \[[Web App](#web-app)] \[[Why This?](#why-this)] \[[Support the Project](#support-the-project)] \[[Installation](#installation)] \[[Configuration](#configuration)] \[[WiKi](https://github.com/deepjyoti30/ytmdl/wiki/)]
<br/>
</div>
## Web App
Ytmdl also has an web app, you can try it out [here](https://ytmdl.deepjyoti30.dev/)
## Why this?
This app downloads a song by getting the audio from Youtube sources **using** youtube-dl and then adds song information like
artist name, album name, release date, thumbnail etc by fetching it from sources like Itunes, Spotify, Gaana and other sources.
**NO**. YoutubeDL doesn't do that. All youtube-dl does is lets you download audio from a video that you specify.
**This app is not yet another youtube-dl clone.**
## Support the Project?
Help the development of this project by becoming a backer or a sponsor.
### [Become a Backer](https://opencollective.com/ytmdl#backer)
### [Become a sponsor](https://opencollective.com/ytmdl#sponsor)
If you like my work, consider buying me a coffee or donating. In case you want to become a patron, join my [Pateron](https://www.patreon.com/deepjyoti30)
<p align="left">
<a href="https://www.paypal.me/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/paypal-deepjyoti30-blue?style=for-the-badge&logo=paypal"></a>
<a href="https://www.patreon.com/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/Patreon-deepjyoti30-orange?style=for-the-badge&logo=patreon"></a>
<a href="https://ko-fi.com/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/KoFi-deepjyoti30-red?style=for-the-badge&logo=ko-fi"></a>
</p>
## Requirements
- Python 3.6.1
- ffmpeg
## Installation
- [PyPi](#pypi)
- [Arch Linux](#arch-linux)
- [Gentoo](#gentoo)
- [NixOS](#nixos)
- [Windows](#windows)
- [Manual](#manual)
### PyPI
```console
pip install ytmdl
```
> NOTE: System wide installation requires `sudo`
### Arch Linux
`ytmdl` is available in AUR as `ytmdl`. It can be found [here](https://aur.archlinux.org/packages/ytmdl/)
> NOTE: The git version is availble as `ytmdl-git` in AUR.
### Gentoo
`ytmdl` can be installed in Gentoo by the following commands
```console
# First set up src_prepare-overlay (as root)
emerge -av --noreplace app-eselect/eselect-repository
eselect repository enable src_prepare-overlay
emaint sync -r src_prepare-overlay
# Finally emerge ytmdl (as root)
emerge -av --autounmask net-misc/ytmdl
```
Available in **src_prepare-overlay** [here](https://gitlab.com/src_prepare/src_prepare-overlay)
### NixOS
`ytmdl` can be installed using Nix with the command
```console
nix-env -iA nixos.ytmdl
```
### Windows
You need to install `ffmpeg` in order for `ytmdl` to work properly. This can be done by downloading the `ffmpeg` binary from [here](https://ffmpeg.org/download.html). Once downloaded, extract the file and find the `ffmpeg.exe` file. Copy the directory's path and add it to PATH in the following way.
```console
setx path "%path%;C:\your\path\here\"
```
Once `ffmpeg` is installed, install `ytmdl` using the following command
```console
pip install ytmdl --upgrade
```
> NOTE: You'll need to have Python 3.6.1 or more installed.
Optionally, also install the latest version of `downloader-cli` and `simber` using the following command:
```console
pip install simber downloader-cli --upgrade
```
### Manual
You can manually install `ytmdl` by cloning this repository and running the `setup.py` script.
1. Install `setuptools` if it isn't already:
```console
pip install setuptools
```
1. Clone this repo:
```console
git clone https://github.com/deepjyoti30/ytmdl
```
1. Move into the `ytmdl` directory and run the `setup.py` script:
```console
cd ytmdl
sudo python setup.py install
```
## Usage
```console
usage: ytmdl [-h] [-q] [-o OUTPUT_DIR] [--song SONG-METADATA]
[--choice CHOICE] [--artist ARTIST] [--album ALBUM]
[--disable-metaadd] [--skip-meta] [-m] [--itunes-id ITUNES_ID]
[--spotify-id SPOTIFY_ID] [--disable-sort] [--ask-meta-name]
[--on-meta-error ON_META_ERROR] [--proxy URL] [--url URL]
[--list PATH TO LIST] [--nolocal] [--format FORMAT] [--trim]
[--version] [--keep-chapter-name] [--download-archive FILE]
[--ignore-chapters] [--ytdl-config PATH] [--dont-transcode]
[--pl-start NUMBER] [--pl-end NUMBER] [--pl-items ITEM_SPEC]
[--ignore-errors] [--title-as-name] [--level LEVEL]
[--disable-file] [--list-level]
[SONG_NAME ...]
positional arguments:
SONG_NAME Name of the song to download. Can be an URL to a
playlist as well. It will be automatically recognized.
options:
-h, --help show this help message and exit
-q, --quiet Don't ask the user to select songs if more than one
search result. The first result in each case will be
considered.
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
The location for the song to be downloaded to. When no
argument is passed, the default locations of SONG_DIR
or XDG_MUSIC_DIR are used.
--proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable
SOCKS proxy, specify a proper scheme. For example
socks5://127.0.0.1:1080/. Pass in an empty string
(--proxy "") for direct connection
--url URL Youtube song link.
--list PATH TO LIST Download list of songs. The list should have one song
name in every line.
--nolocal Don't search locally for the song before downloading.
--format FORMAT The format in which the song should be downloaded.
Default is mp3, but can be set in config. Available
options are ['mp3', 'm4a', 'opus']
--trim, -t Trim out the audio from the song. Use underlying
speech and music segmentation engine to determine and
keep only the music in the file. Useful in songs where
there are speeches, noise etc before/after the start
of the song. Default is false.
--version show the program version number and exit
--keep-chapter-name Keep the title extracted from the chapter in order to
search for the metadata. If not passed, the user will
be asked if they'd like to change the title with which
the metadata will be searched.
--download-archive FILE
Skip downloading songs that are present in the passed
file. The songs are matched by using the videoId. All
downloaded song Id's are automatically added to the
file.
--ignore-chapters Ignore chapters if available in the video and treat it
like one video
--ytdl-config PATH Path to the youtube-dl config location or the
directory
--dont-transcode Don't transcode the audio after downloading.
Applicable for OPUS format only. (Default: false)
Metadata:
--song SONG-METADATA The song to search in Metadata. Particularly useful
for songs that have the names in a different language
in YouTube. For Example, greek songs.
--choice CHOICE The choice that the user wants to go for. Usefull to
pass along with --quiet. Choices start at 1
--artist ARTIST The name of the song's artist. Pass it with a song
name.
--album ALBUM The name of the song's album. Pass it with a song
name.
--disable-metaadd Disable addition of passed artist and album keyword to
the youtube search in order to get a more accurate
result. (Default: false)
--skip-meta Skip setting the metadata and just copy the converted
song to the destination directory. '--manual-meta'
will override this option, pass only one of them.
-m, --manual-meta Manually enter song details.
--itunes-id ITUNES_ID
Direct lookup from itunes. If passed, metadata will be
automatically added.
--spotify-id SPOTIFY_ID
Direct lookup for Spotify tracks using the ID. If
passed, metadata will be automatically added.
--disable-sort Disable sorting of the metadata before asking for
input. Useful if the song is in some other language
and/or just a few providers are used.
--ask-meta-name Ask the user to enter a separate name for searching
the metadata (Default: false)
--on-meta-error ON_META_ERROR
What to do if adding the metadata fails for some
reason like lack of metadata or perhaps a network
issue. Options are ['exit', 'skip', 'manual']
Playlist:
--pl-start NUMBER Playlist video to start at (default is 1)
--pl-end NUMBER Playlist video to end at (default is last)
--pl-items ITEM_SPEC Playlist video items to download. Specify indices of
the videos present in the playlist separated by commas
like: '--playlist-items 1, 2, 4, 6' if you want to
download videos indexed 1, 2, 4 and 6. Range can also
be passed like: '--playlist-items 1-3, 5-7' to
download the videos indexed at 1, 2, 3, 5, 6, 7.
--ignore-errors Ignore if downloading any video fails in a playlist.
If passed, the execution will move to the next video
in the passed playlist.
--title-as-name Use the title of the video as the name of the song to
search for metadata. If not passed, user will be asked
if they want to use a different name and continue
accordingly.
Logger:
--level LEVEL The level of the logger that will be used while
verbosing. Use `--list-level` to check available
options.
--disable-file Disable logging to files
--list-level List all the available logger levels.
```
## Configuration
### Setup
The defaults can be changed by editing the config file in ytmdl folder in your .config folder
The config will be created automatically the first time you run `ytmdl` and will be present in ~/.config/ytmdl/config
However, it can be created manually by the following command
```console
mkdir -p ~/.config/ytmdl; curl https://raw.githubusercontent.com/deepjyoti30/ytmdl/master/examples/config > ~/.config/ytmdl/config
```
Above command will download the config from the repo and save it in the `~/.config/ytmdl/` directory.
### Supported Options
As of the latest development branch, the following options can be changed from the config
| Name | Description | Default |
| :------------------: | ------------------------------------------------ | ------------------------------ |
| `SONG_DIR` | Directory to save the songs in after editing | Current directory |
| `SONG_QUALITY` | Quality of the song | 320kbps |
| `METADATA_PROVIDERS` | Which API providers to use for metadata | all supported options are used |
| `DEFAULT_FORMAT` | Default format of the song | mp3 |
| `ON_META_ERROR` | What to do if error occurs while writing meta | exit |
| `ITUNES_COUNTRY` | Which region to use while searching from Itunes | US |
| `SPOTIFY_COUNTRY` | Which market to use while searching from Spotify | US |
### Advanced Configuration
#### Dynamically storing songs
`SONG_DIR` field also takes values that are extracted from the song being downloaded
The `SONG_DIR` field needs to be passed some special values in order to achieve that. The string is scanned and when a `$` sign occurs, the special string will start and each directory can be separated by using an `->` sign.
To save the song in the `/dir/<album_name>/<artist_name>/<title>/<song_name>.mp3` format, the following needs to be added in the `SONG_DIR` field.
```
SONG_DIR="/dir$Album->Artist->Title"
```
Above will extract to the following directory structure when a song named `Cradles` by artist `Sub Urban` from the album `Cradles - Single`
```
|--dir
|--Cradles - Single
|--Sub Urban
|--Cradles
|--Cradles.mp3
```
In order to pass the name with which the song should be saved, the last attribute can be passed between `[]`.
If the `SONG_DIR` field is `/dir$Album->[Artist]` will extract to the following directory structure
```
|--dir
|--Cradles - Single
|--Sub Urban.mp3
```
#### Supported options for dynamic storing
As of the latest source, the following options can be passed to the special string in order to create dynamic directories
| Name | |
| :-----------: | ----------------------- |
| `Artist` | Artist Of the Song |
| `Album` | Album Of the Song |
| `Title` | Title Of the Song |
| `Genre` | Genre Of the Song |
| `TrackNumber` | TrackNumber Of the Song |
| `ReleaseDate` | ReleaseDate Of the Song |
%package -n python3-ytmdl
Summary: Youtube Music Downloader
Provides: python-ytmdl
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-ytmdl
<div align="center">
<img src=".github/ytmdl.png">
</div>
<div align="center">
<h1>YouTube Music Downloader</h1>
<h4>Download songs from YouTube by getting the audio from YouTube and the metadata from sources like Itunes, Spotify, Gaana etc.</h4>
</div>
<div align="center" width="60%" height="auto">
<br>
<img src=".github/ytmdl.gif">
</div>
<div align="center">
<br/>
[](https://www.python.org/)<br/><br/>
<img src="https://img.shields.io/badge/Maintained%3F-Yes-blueviolet?style=for-the-badge">
 ](https://apis.deepjyoti30.dev/repostatus/badge?repo=deepjyoti30%2Fytmdl&style=for-the-badge) [](LICENSE.md)   [](https://img.shields.io/badge/dynamic/json?style=for-the-badge&maxAge=86400&label=downloads&query=%24.total_downloads&url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2Fytmdl) [](http://makeapullrequest.com) [](https://t.me/ytmdl)
<p>
<a href="https://ko-fi.com/deepjyoti30"><img src="https://raw.githubusercontent.com/adi1090x/files/master/other/kofi.png" alt="Support me on ko-fi"></a>
</p>
<br/>
### \[[Web App](#web-app)] \[[Why This?](#why-this)] \[[Support the Project](#support-the-project)] \[[Installation](#installation)] \[[Configuration](#configuration)] \[[WiKi](https://github.com/deepjyoti30/ytmdl/wiki/)]
<br/>
</div>
## Web App
Ytmdl also has an web app, you can try it out [here](https://ytmdl.deepjyoti30.dev/)
## Why this?
This app downloads a song by getting the audio from Youtube sources **using** youtube-dl and then adds song information like
artist name, album name, release date, thumbnail etc by fetching it from sources like Itunes, Spotify, Gaana and other sources.
**NO**. YoutubeDL doesn't do that. All youtube-dl does is lets you download audio from a video that you specify.
**This app is not yet another youtube-dl clone.**
## Support the Project?
Help the development of this project by becoming a backer or a sponsor.
### [Become a Backer](https://opencollective.com/ytmdl#backer)
### [Become a sponsor](https://opencollective.com/ytmdl#sponsor)
If you like my work, consider buying me a coffee or donating. In case you want to become a patron, join my [Pateron](https://www.patreon.com/deepjyoti30)
<p align="left">
<a href="https://www.paypal.me/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/paypal-deepjyoti30-blue?style=for-the-badge&logo=paypal"></a>
<a href="https://www.patreon.com/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/Patreon-deepjyoti30-orange?style=for-the-badge&logo=patreon"></a>
<a href="https://ko-fi.com/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/KoFi-deepjyoti30-red?style=for-the-badge&logo=ko-fi"></a>
</p>
## Requirements
- Python 3.6.1
- ffmpeg
## Installation
- [PyPi](#pypi)
- [Arch Linux](#arch-linux)
- [Gentoo](#gentoo)
- [NixOS](#nixos)
- [Windows](#windows)
- [Manual](#manual)
### PyPI
```console
pip install ytmdl
```
> NOTE: System wide installation requires `sudo`
### Arch Linux
`ytmdl` is available in AUR as `ytmdl`. It can be found [here](https://aur.archlinux.org/packages/ytmdl/)
> NOTE: The git version is availble as `ytmdl-git` in AUR.
### Gentoo
`ytmdl` can be installed in Gentoo by the following commands
```console
# First set up src_prepare-overlay (as root)
emerge -av --noreplace app-eselect/eselect-repository
eselect repository enable src_prepare-overlay
emaint sync -r src_prepare-overlay
# Finally emerge ytmdl (as root)
emerge -av --autounmask net-misc/ytmdl
```
Available in **src_prepare-overlay** [here](https://gitlab.com/src_prepare/src_prepare-overlay)
### NixOS
`ytmdl` can be installed using Nix with the command
```console
nix-env -iA nixos.ytmdl
```
### Windows
You need to install `ffmpeg` in order for `ytmdl` to work properly. This can be done by downloading the `ffmpeg` binary from [here](https://ffmpeg.org/download.html). Once downloaded, extract the file and find the `ffmpeg.exe` file. Copy the directory's path and add it to PATH in the following way.
```console
setx path "%path%;C:\your\path\here\"
```
Once `ffmpeg` is installed, install `ytmdl` using the following command
```console
pip install ytmdl --upgrade
```
> NOTE: You'll need to have Python 3.6.1 or more installed.
Optionally, also install the latest version of `downloader-cli` and `simber` using the following command:
```console
pip install simber downloader-cli --upgrade
```
### Manual
You can manually install `ytmdl` by cloning this repository and running the `setup.py` script.
1. Install `setuptools` if it isn't already:
```console
pip install setuptools
```
1. Clone this repo:
```console
git clone https://github.com/deepjyoti30/ytmdl
```
1. Move into the `ytmdl` directory and run the `setup.py` script:
```console
cd ytmdl
sudo python setup.py install
```
## Usage
```console
usage: ytmdl [-h] [-q] [-o OUTPUT_DIR] [--song SONG-METADATA]
[--choice CHOICE] [--artist ARTIST] [--album ALBUM]
[--disable-metaadd] [--skip-meta] [-m] [--itunes-id ITUNES_ID]
[--spotify-id SPOTIFY_ID] [--disable-sort] [--ask-meta-name]
[--on-meta-error ON_META_ERROR] [--proxy URL] [--url URL]
[--list PATH TO LIST] [--nolocal] [--format FORMAT] [--trim]
[--version] [--keep-chapter-name] [--download-archive FILE]
[--ignore-chapters] [--ytdl-config PATH] [--dont-transcode]
[--pl-start NUMBER] [--pl-end NUMBER] [--pl-items ITEM_SPEC]
[--ignore-errors] [--title-as-name] [--level LEVEL]
[--disable-file] [--list-level]
[SONG_NAME ...]
positional arguments:
SONG_NAME Name of the song to download. Can be an URL to a
playlist as well. It will be automatically recognized.
options:
-h, --help show this help message and exit
-q, --quiet Don't ask the user to select songs if more than one
search result. The first result in each case will be
considered.
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
The location for the song to be downloaded to. When no
argument is passed, the default locations of SONG_DIR
or XDG_MUSIC_DIR are used.
--proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable
SOCKS proxy, specify a proper scheme. For example
socks5://127.0.0.1:1080/. Pass in an empty string
(--proxy "") for direct connection
--url URL Youtube song link.
--list PATH TO LIST Download list of songs. The list should have one song
name in every line.
--nolocal Don't search locally for the song before downloading.
--format FORMAT The format in which the song should be downloaded.
Default is mp3, but can be set in config. Available
options are ['mp3', 'm4a', 'opus']
--trim, -t Trim out the audio from the song. Use underlying
speech and music segmentation engine to determine and
keep only the music in the file. Useful in songs where
there are speeches, noise etc before/after the start
of the song. Default is false.
--version show the program version number and exit
--keep-chapter-name Keep the title extracted from the chapter in order to
search for the metadata. If not passed, the user will
be asked if they'd like to change the title with which
the metadata will be searched.
--download-archive FILE
Skip downloading songs that are present in the passed
file. The songs are matched by using the videoId. All
downloaded song Id's are automatically added to the
file.
--ignore-chapters Ignore chapters if available in the video and treat it
like one video
--ytdl-config PATH Path to the youtube-dl config location or the
directory
--dont-transcode Don't transcode the audio after downloading.
Applicable for OPUS format only. (Default: false)
Metadata:
--song SONG-METADATA The song to search in Metadata. Particularly useful
for songs that have the names in a different language
in YouTube. For Example, greek songs.
--choice CHOICE The choice that the user wants to go for. Usefull to
pass along with --quiet. Choices start at 1
--artist ARTIST The name of the song's artist. Pass it with a song
name.
--album ALBUM The name of the song's album. Pass it with a song
name.
--disable-metaadd Disable addition of passed artist and album keyword to
the youtube search in order to get a more accurate
result. (Default: false)
--skip-meta Skip setting the metadata and just copy the converted
song to the destination directory. '--manual-meta'
will override this option, pass only one of them.
-m, --manual-meta Manually enter song details.
--itunes-id ITUNES_ID
Direct lookup from itunes. If passed, metadata will be
automatically added.
--spotify-id SPOTIFY_ID
Direct lookup for Spotify tracks using the ID. If
passed, metadata will be automatically added.
--disable-sort Disable sorting of the metadata before asking for
input. Useful if the song is in some other language
and/or just a few providers are used.
--ask-meta-name Ask the user to enter a separate name for searching
the metadata (Default: false)
--on-meta-error ON_META_ERROR
What to do if adding the metadata fails for some
reason like lack of metadata or perhaps a network
issue. Options are ['exit', 'skip', 'manual']
Playlist:
--pl-start NUMBER Playlist video to start at (default is 1)
--pl-end NUMBER Playlist video to end at (default is last)
--pl-items ITEM_SPEC Playlist video items to download. Specify indices of
the videos present in the playlist separated by commas
like: '--playlist-items 1, 2, 4, 6' if you want to
download videos indexed 1, 2, 4 and 6. Range can also
be passed like: '--playlist-items 1-3, 5-7' to
download the videos indexed at 1, 2, 3, 5, 6, 7.
--ignore-errors Ignore if downloading any video fails in a playlist.
If passed, the execution will move to the next video
in the passed playlist.
--title-as-name Use the title of the video as the name of the song to
search for metadata. If not passed, user will be asked
if they want to use a different name and continue
accordingly.
Logger:
--level LEVEL The level of the logger that will be used while
verbosing. Use `--list-level` to check available
options.
--disable-file Disable logging to files
--list-level List all the available logger levels.
```
## Configuration
### Setup
The defaults can be changed by editing the config file in ytmdl folder in your .config folder
The config will be created automatically the first time you run `ytmdl` and will be present in ~/.config/ytmdl/config
However, it can be created manually by the following command
```console
mkdir -p ~/.config/ytmdl; curl https://raw.githubusercontent.com/deepjyoti30/ytmdl/master/examples/config > ~/.config/ytmdl/config
```
Above command will download the config from the repo and save it in the `~/.config/ytmdl/` directory.
### Supported Options
As of the latest development branch, the following options can be changed from the config
| Name | Description | Default |
| :------------------: | ------------------------------------------------ | ------------------------------ |
| `SONG_DIR` | Directory to save the songs in after editing | Current directory |
| `SONG_QUALITY` | Quality of the song | 320kbps |
| `METADATA_PROVIDERS` | Which API providers to use for metadata | all supported options are used |
| `DEFAULT_FORMAT` | Default format of the song | mp3 |
| `ON_META_ERROR` | What to do if error occurs while writing meta | exit |
| `ITUNES_COUNTRY` | Which region to use while searching from Itunes | US |
| `SPOTIFY_COUNTRY` | Which market to use while searching from Spotify | US |
### Advanced Configuration
#### Dynamically storing songs
`SONG_DIR` field also takes values that are extracted from the song being downloaded
The `SONG_DIR` field needs to be passed some special values in order to achieve that. The string is scanned and when a `$` sign occurs, the special string will start and each directory can be separated by using an `->` sign.
To save the song in the `/dir/<album_name>/<artist_name>/<title>/<song_name>.mp3` format, the following needs to be added in the `SONG_DIR` field.
```
SONG_DIR="/dir$Album->Artist->Title"
```
Above will extract to the following directory structure when a song named `Cradles` by artist `Sub Urban` from the album `Cradles - Single`
```
|--dir
|--Cradles - Single
|--Sub Urban
|--Cradles
|--Cradles.mp3
```
In order to pass the name with which the song should be saved, the last attribute can be passed between `[]`.
If the `SONG_DIR` field is `/dir$Album->[Artist]` will extract to the following directory structure
```
|--dir
|--Cradles - Single
|--Sub Urban.mp3
```
#### Supported options for dynamic storing
As of the latest source, the following options can be passed to the special string in order to create dynamic directories
| Name | |
| :-----------: | ----------------------- |
| `Artist` | Artist Of the Song |
| `Album` | Album Of the Song |
| `Title` | Title Of the Song |
| `Genre` | Genre Of the Song |
| `TrackNumber` | TrackNumber Of the Song |
| `ReleaseDate` | ReleaseDate Of the Song |
%package help
Summary: Development documents and examples for ytmdl
Provides: python3-ytmdl-doc
%description help
<div align="center">
<img src=".github/ytmdl.png">
</div>
<div align="center">
<h1>YouTube Music Downloader</h1>
<h4>Download songs from YouTube by getting the audio from YouTube and the metadata from sources like Itunes, Spotify, Gaana etc.</h4>
</div>
<div align="center" width="60%" height="auto">
<br>
<img src=".github/ytmdl.gif">
</div>
<div align="center">
<br/>
[](https://www.python.org/)<br/><br/>
<img src="https://img.shields.io/badge/Maintained%3F-Yes-blueviolet?style=for-the-badge">
 ](https://apis.deepjyoti30.dev/repostatus/badge?repo=deepjyoti30%2Fytmdl&style=for-the-badge) [](LICENSE.md)   [](https://img.shields.io/badge/dynamic/json?style=for-the-badge&maxAge=86400&label=downloads&query=%24.total_downloads&url=https%3A%2F%2Fapi.pepy.tech%2Fapi%2Fprojects%2Fytmdl) [](http://makeapullrequest.com) [](https://t.me/ytmdl)
<p>
<a href="https://ko-fi.com/deepjyoti30"><img src="https://raw.githubusercontent.com/adi1090x/files/master/other/kofi.png" alt="Support me on ko-fi"></a>
</p>
<br/>
### \[[Web App](#web-app)] \[[Why This?](#why-this)] \[[Support the Project](#support-the-project)] \[[Installation](#installation)] \[[Configuration](#configuration)] \[[WiKi](https://github.com/deepjyoti30/ytmdl/wiki/)]
<br/>
</div>
## Web App
Ytmdl also has an web app, you can try it out [here](https://ytmdl.deepjyoti30.dev/)
## Why this?
This app downloads a song by getting the audio from Youtube sources **using** youtube-dl and then adds song information like
artist name, album name, release date, thumbnail etc by fetching it from sources like Itunes, Spotify, Gaana and other sources.
**NO**. YoutubeDL doesn't do that. All youtube-dl does is lets you download audio from a video that you specify.
**This app is not yet another youtube-dl clone.**
## Support the Project?
Help the development of this project by becoming a backer or a sponsor.
### [Become a Backer](https://opencollective.com/ytmdl#backer)
### [Become a sponsor](https://opencollective.com/ytmdl#sponsor)
If you like my work, consider buying me a coffee or donating. In case you want to become a patron, join my [Pateron](https://www.patreon.com/deepjyoti30)
<p align="left">
<a href="https://www.paypal.me/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/paypal-deepjyoti30-blue?style=for-the-badge&logo=paypal"></a>
<a href="https://www.patreon.com/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/Patreon-deepjyoti30-orange?style=for-the-badge&logo=patreon"></a>
<a href="https://ko-fi.com/deepjyoti30" target="_blank"><img alt="undefined" src="https://img.shields.io/badge/KoFi-deepjyoti30-red?style=for-the-badge&logo=ko-fi"></a>
</p>
## Requirements
- Python 3.6.1
- ffmpeg
## Installation
- [PyPi](#pypi)
- [Arch Linux](#arch-linux)
- [Gentoo](#gentoo)
- [NixOS](#nixos)
- [Windows](#windows)
- [Manual](#manual)
### PyPI
```console
pip install ytmdl
```
> NOTE: System wide installation requires `sudo`
### Arch Linux
`ytmdl` is available in AUR as `ytmdl`. It can be found [here](https://aur.archlinux.org/packages/ytmdl/)
> NOTE: The git version is availble as `ytmdl-git` in AUR.
### Gentoo
`ytmdl` can be installed in Gentoo by the following commands
```console
# First set up src_prepare-overlay (as root)
emerge -av --noreplace app-eselect/eselect-repository
eselect repository enable src_prepare-overlay
emaint sync -r src_prepare-overlay
# Finally emerge ytmdl (as root)
emerge -av --autounmask net-misc/ytmdl
```
Available in **src_prepare-overlay** [here](https://gitlab.com/src_prepare/src_prepare-overlay)
### NixOS
`ytmdl` can be installed using Nix with the command
```console
nix-env -iA nixos.ytmdl
```
### Windows
You need to install `ffmpeg` in order for `ytmdl` to work properly. This can be done by downloading the `ffmpeg` binary from [here](https://ffmpeg.org/download.html). Once downloaded, extract the file and find the `ffmpeg.exe` file. Copy the directory's path and add it to PATH in the following way.
```console
setx path "%path%;C:\your\path\here\"
```
Once `ffmpeg` is installed, install `ytmdl` using the following command
```console
pip install ytmdl --upgrade
```
> NOTE: You'll need to have Python 3.6.1 or more installed.
Optionally, also install the latest version of `downloader-cli` and `simber` using the following command:
```console
pip install simber downloader-cli --upgrade
```
### Manual
You can manually install `ytmdl` by cloning this repository and running the `setup.py` script.
1. Install `setuptools` if it isn't already:
```console
pip install setuptools
```
1. Clone this repo:
```console
git clone https://github.com/deepjyoti30/ytmdl
```
1. Move into the `ytmdl` directory and run the `setup.py` script:
```console
cd ytmdl
sudo python setup.py install
```
## Usage
```console
usage: ytmdl [-h] [-q] [-o OUTPUT_DIR] [--song SONG-METADATA]
[--choice CHOICE] [--artist ARTIST] [--album ALBUM]
[--disable-metaadd] [--skip-meta] [-m] [--itunes-id ITUNES_ID]
[--spotify-id SPOTIFY_ID] [--disable-sort] [--ask-meta-name]
[--on-meta-error ON_META_ERROR] [--proxy URL] [--url URL]
[--list PATH TO LIST] [--nolocal] [--format FORMAT] [--trim]
[--version] [--keep-chapter-name] [--download-archive FILE]
[--ignore-chapters] [--ytdl-config PATH] [--dont-transcode]
[--pl-start NUMBER] [--pl-end NUMBER] [--pl-items ITEM_SPEC]
[--ignore-errors] [--title-as-name] [--level LEVEL]
[--disable-file] [--list-level]
[SONG_NAME ...]
positional arguments:
SONG_NAME Name of the song to download. Can be an URL to a
playlist as well. It will be automatically recognized.
options:
-h, --help show this help message and exit
-q, --quiet Don't ask the user to select songs if more than one
search result. The first result in each case will be
considered.
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
The location for the song to be downloaded to. When no
argument is passed, the default locations of SONG_DIR
or XDG_MUSIC_DIR are used.
--proxy URL Use the specified HTTP/HTTPS/SOCKS proxy. To enable
SOCKS proxy, specify a proper scheme. For example
socks5://127.0.0.1:1080/. Pass in an empty string
(--proxy "") for direct connection
--url URL Youtube song link.
--list PATH TO LIST Download list of songs. The list should have one song
name in every line.
--nolocal Don't search locally for the song before downloading.
--format FORMAT The format in which the song should be downloaded.
Default is mp3, but can be set in config. Available
options are ['mp3', 'm4a', 'opus']
--trim, -t Trim out the audio from the song. Use underlying
speech and music segmentation engine to determine and
keep only the music in the file. Useful in songs where
there are speeches, noise etc before/after the start
of the song. Default is false.
--version show the program version number and exit
--keep-chapter-name Keep the title extracted from the chapter in order to
search for the metadata. If not passed, the user will
be asked if they'd like to change the title with which
the metadata will be searched.
--download-archive FILE
Skip downloading songs that are present in the passed
file. The songs are matched by using the videoId. All
downloaded song Id's are automatically added to the
file.
--ignore-chapters Ignore chapters if available in the video and treat it
like one video
--ytdl-config PATH Path to the youtube-dl config location or the
directory
--dont-transcode Don't transcode the audio after downloading.
Applicable for OPUS format only. (Default: false)
Metadata:
--song SONG-METADATA The song to search in Metadata. Particularly useful
for songs that have the names in a different language
in YouTube. For Example, greek songs.
--choice CHOICE The choice that the user wants to go for. Usefull to
pass along with --quiet. Choices start at 1
--artist ARTIST The name of the song's artist. Pass it with a song
name.
--album ALBUM The name of the song's album. Pass it with a song
name.
--disable-metaadd Disable addition of passed artist and album keyword to
the youtube search in order to get a more accurate
result. (Default: false)
--skip-meta Skip setting the metadata and just copy the converted
song to the destination directory. '--manual-meta'
will override this option, pass only one of them.
-m, --manual-meta Manually enter song details.
--itunes-id ITUNES_ID
Direct lookup from itunes. If passed, metadata will be
automatically added.
--spotify-id SPOTIFY_ID
Direct lookup for Spotify tracks using the ID. If
passed, metadata will be automatically added.
--disable-sort Disable sorting of the metadata before asking for
input. Useful if the song is in some other language
and/or just a few providers are used.
--ask-meta-name Ask the user to enter a separate name for searching
the metadata (Default: false)
--on-meta-error ON_META_ERROR
What to do if adding the metadata fails for some
reason like lack of metadata or perhaps a network
issue. Options are ['exit', 'skip', 'manual']
Playlist:
--pl-start NUMBER Playlist video to start at (default is 1)
--pl-end NUMBER Playlist video to end at (default is last)
--pl-items ITEM_SPEC Playlist video items to download. Specify indices of
the videos present in the playlist separated by commas
like: '--playlist-items 1, 2, 4, 6' if you want to
download videos indexed 1, 2, 4 and 6. Range can also
be passed like: '--playlist-items 1-3, 5-7' to
download the videos indexed at 1, 2, 3, 5, 6, 7.
--ignore-errors Ignore if downloading any video fails in a playlist.
If passed, the execution will move to the next video
in the passed playlist.
--title-as-name Use the title of the video as the name of the song to
search for metadata. If not passed, user will be asked
if they want to use a different name and continue
accordingly.
Logger:
--level LEVEL The level of the logger that will be used while
verbosing. Use `--list-level` to check available
options.
--disable-file Disable logging to files
--list-level List all the available logger levels.
```
## Configuration
### Setup
The defaults can be changed by editing the config file in ytmdl folder in your .config folder
The config will be created automatically the first time you run `ytmdl` and will be present in ~/.config/ytmdl/config
However, it can be created manually by the following command
```console
mkdir -p ~/.config/ytmdl; curl https://raw.githubusercontent.com/deepjyoti30/ytmdl/master/examples/config > ~/.config/ytmdl/config
```
Above command will download the config from the repo and save it in the `~/.config/ytmdl/` directory.
### Supported Options
As of the latest development branch, the following options can be changed from the config
| Name | Description | Default |
| :------------------: | ------------------------------------------------ | ------------------------------ |
| `SONG_DIR` | Directory to save the songs in after editing | Current directory |
| `SONG_QUALITY` | Quality of the song | 320kbps |
| `METADATA_PROVIDERS` | Which API providers to use for metadata | all supported options are used |
| `DEFAULT_FORMAT` | Default format of the song | mp3 |
| `ON_META_ERROR` | What to do if error occurs while writing meta | exit |
| `ITUNES_COUNTRY` | Which region to use while searching from Itunes | US |
| `SPOTIFY_COUNTRY` | Which market to use while searching from Spotify | US |
### Advanced Configuration
#### Dynamically storing songs
`SONG_DIR` field also takes values that are extracted from the song being downloaded
The `SONG_DIR` field needs to be passed some special values in order to achieve that. The string is scanned and when a `$` sign occurs, the special string will start and each directory can be separated by using an `->` sign.
To save the song in the `/dir/<album_name>/<artist_name>/<title>/<song_name>.mp3` format, the following needs to be added in the `SONG_DIR` field.
```
SONG_DIR="/dir$Album->Artist->Title"
```
Above will extract to the following directory structure when a song named `Cradles` by artist `Sub Urban` from the album `Cradles - Single`
```
|--dir
|--Cradles - Single
|--Sub Urban
|--Cradles
|--Cradles.mp3
```
In order to pass the name with which the song should be saved, the last attribute can be passed between `[]`.
If the `SONG_DIR` field is `/dir$Album->[Artist]` will extract to the following directory structure
```
|--dir
|--Cradles - Single
|--Sub Urban.mp3
```
#### Supported options for dynamic storing
As of the latest source, the following options can be passed to the special string in order to create dynamic directories
| Name | |
| :-----------: | ----------------------- |
| `Artist` | Artist Of the Song |
| `Album` | Album Of the Song |
| `Title` | Title Of the Song |
| `Genre` | Genre Of the Song |
| `TrackNumber` | TrackNumber Of the Song |
| `ReleaseDate` | ReleaseDate Of the Song |
%prep
%autosetup -n ytmdl-2023.2.28
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-ytmdl -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Thu Jun 08 2023 Python_Bot <Python_Bot@openeuler.org> - 2023.2.28-1
- Package Spec generated
|