blob: 839c2d4977d3d40286d34aa3e2ee7a5a85e73d78 (
plain)
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
|
# m2m
A minimal bash tool to convert YouTube video files to any other supported media files.
"m2m" stands for **Media to Media**.
## How it works:
- Fetches the video from the URL using yt-dlp
- Saves it in your `$YTDIR` directory (`$YTDIR=$HOME/Music/ytdownloads` by default)
- Or in your `$MULTI_DIR` directory for batch downloads (`$MULTI_DIR=$HOME/Music/ytdownloads/multi_mode` by default)
- Uses ffmpeg to convert the video to another file format
- Deletes the original video file and saves the converted file to `$YTDIR`
## Dependencies
- [yt-dlp](https://github.com/yt-dlp/yt-dlp)
- [ffmpeg](https://ffmpeg.org/)
## Usage:
### For single downloads:
```bash
m2m "https://www.youtube.com/watch?v=EYI489Dc4Sc" outputfile.mp3
```
Change the extension form `.mp3` to anything you like.
### For batch downloads:
```bash
m2m -m 5
```
You can change the **5** to the number of files you want to download.
(Or you can set is as **n** if you want it to run infinitely until you type `done` as the url.)
It would prompt you for the *URL* and then for the name you want to save the file as
```bash
m2m -m 2
Enter the URL: https://youtu.be/3JZ_D3ELwOQ
Enter the name to save it as: song_one.wav
Enter the URL: https://youtu.be/L_jWHffIx5E
Enter the name to save it as: song_two.mkv
[*] Initiating download for stream 1
[✓] Stream 1 downloaded
[*] Converting stream 1
[✓] Stream 1 saved to filesystem
[*] Initiating download for stream 2
[✓] Stream 2 downloaded
[*] Converting stream 2
[✓] Stream 2 saved to filesystem
... #And so on
```
### Infinite batch downloads:
```bash
m2m -m n
Enter the URL(type 'done' when you are done): https://youtu.be/oUfjhrSOFw8?si=GGCoI5J-5w4ejof-
Enter the name to save it as: stream01.mp4
Enter the URL(type 'done' when you are done): https://youtu.be/wN0x9eZLix4?si=2OXL-z7ldy7gAckO
Enter the name to save it as: stream02.mp4
Enter the URL(type 'done' when you are done): done
[*] Initiating download for stream 1
[✓] Stream 1 downloaded
[*] Converting stream 1
[✓] Stream 1 saved to filesystem
[*] Initiating download for stream 2
[✓] Stream 2 downloaded
[*] Converting stream 2
[✓] Stream 2 saved to filesystem
```
## Notes
- By default, downloads are saved in `$HOME/Music/ytdownloads` for single downloads,and `$HOME/Music/ytdownloads/multi_mode` for batch downloads.
- You can add the `-o` flag followed by any _path_ to have **m2m** save the file(s) there.
- You can change both `$YTDIR` and `$MULTI_DIR` as per your convenience.
- You can convert to any media format supported by `ffmpeg` just don't forget to put the extension after the file name.
- I have used `-f best` option for `yt-dlp` to fetch the highest quality stream available, however if you want to optimize `m2m` for less data usage, you can change that to any other stream you like.
## Contributers
- Big thanks to [hamed](https://github.com/hamedbkf) for adding the output directory flag `-o` and replacing `--cwd`
## Support
m2m was built mostly because I wanted it to exist.
If it helps you too, and you’d like to buy me a coffee (no pressure at all), you can tip a few sats here:
**BTC (On-chain):**
`bc1qsjjgj3yqvhe5dw0xlxqzch4zlqnlwqctchlztf`
Every bit goes straight into caffeine and maintaining open-source code.
|