-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileDown.sh
executable file
·157 lines (141 loc) · 6.99 KB
/
fileDown.sh
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
#!/bin/bash
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# NAME: fileDowmn ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# DESC: Downloads files passed to it, tagging mp3s as needed. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# CREATED: 2021-01-10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# MODIFIED: 2021-02-21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# CONTACT: [email protected] && https://github.com/alephalpha0 ;;;;;;;;;;;;;;;;;;;;;;;;#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# Many thanks to those who have shared and discussed their dotfiles/source code/scripts on #
# blogs, stackoverflow, dev.to, gitlab/github, and on any open forum for ideas on the world #
# wide web. I am continually learning and finding new things because of you. #
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
#;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#
# fileDown - Downloads URLs passed to it, using wget and youtube-dl. Tags MP3s TOO!.
# Copyright (C) 20201 alephalpha0 [[email protected]]
# This program is free software: you can redistribute it and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# LOVELY VARIABLES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# (String) The URL passed to the script ;;;;;;;;;;;;;;;;;;;;;;
file2dl="${1}"
# (String) The local directory to download into. ;;;;;;;;;;;;;
directory=""
# (Int) The User Selected Download Method. ;;;;;;;;;;;;;;;;;;;
dlmethod=""
# (String) The createdMP3 file ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mp3File=""
printLine() {
echo "::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
return 0;
}
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# the logic train of the script cho cho ;;;;;;;;;;;;;;;;;;;;;;
if [ -z "${file2dl}" ]; then
echo "I wasnt passed a valid url."
return 1
fi
printLine
echo " ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░2 "
echo " ░█▀▀░▀█▀░█░░░█▀▀░█▀▄░█▀█░█░█░█▀█░0 "
echo " ░█▀▀░░█░░█░░░█▀▀░█░█░█░█░█▄█░█░█░2 "
echo " ░▀░░░▀▀▀░▀▀▀░▀▀▀░▀▀░░▀▀▀░▀░▀░▀░▀░1 "
printLine
echo "::::::::: What directory to download to? :::::::::::::::"
printLine
read -r directory
printLine
echo "Downloading into:" "${directory}"
if [ -d "${HOME}/${directory}" ]; then
cd "${HOME}/${directory}" || exit $?
else
mkdir "${HOME}/${directory}"
cd "${HOME}/${directory}" || exit $?
fi
printLine
echo "::::::::: What method are we using today? ::::::::::::::"
echo "(:::1:::) WGET:: single file download. :::::::::::::::::"
echo "(:::2:::) YOUTUBE-DL:: music into mp3. :::::::::::::::::"
echo "(:::3:::) YOUTUBE-DL:: single mp4 download :::::::::::::"
read -r dlmethod
while [ "${dlmethod}" -gt 3 ] || [ "${dlmethod}" -lt 1 ]
do
echo "(:::!:::) Make a valid selection. ::::::::::::::::::::::"
read -r dlmethod
done
case "${dlmethod}" in
1)
printLine
echo "::::::::: Downloading file via wget into ~/${directory}"
wget "${file2dl}"
exit 0
;;
2)
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# MP3 RENAMING AND TAGGING VARIABLES ;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# (String) Date this ripping occured. ;;;;;;;;;;;;;;;;;;;;;;;;
ripDate=""
# (String) Artist Name ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mp3Artist=""
# (String) Song Title ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
mp3Title=""
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# Get the current date for the rip date.
printf -v ripDate '%(%B %d, %Y)T' -1
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# GETTING MP3 ARTIST AND TITLE FOR TAGGING ;;;;;;;;;;;;;;;;;;;
printLine
echo "::::::::: Artist name? ::::::::::::::::::::::::::::::::::"
printLine
read -r mp3Artist
while [ -z "${mp3Artist}" ]; do
echo "(:::!:::) Enter a valid string. ::::::::::::::::::::::::"
read -r mp3Artist
done
printLine
echo "::::::::: Song title? :::::::::::::::::::::::::::::::::::"
printLine
read -r mp3Title
while [ -z "${mp3Title}" ]; do
echo "(:::!:::) Enter a valid string. ::::::::::::::::::::::::"
read -r mp3Title
done
## END USER INPUT FOR TAGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# DOWNLOAD FILE AND ENCODE INTO MP3 ;;;;;;;;;;;;;;;;;;;;;;;;;;
echo "Downloading youtube[music] link into mp3 :::::::::::::"
youtube-dl --restrict-filenames -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 -c "${file2dl}" -o "${mp3Artist}"'-'"${mp3Title}"'.%(ext)s'
mp3File="${mp3Artist}"'-'"${mp3Title}"'.mp3'
printLine
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
# MP3 TAGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
echo "Writing default id3 tags. ::::::::::::::::::::::::::::"
mid3v2 -ve -a "${mp3Artist}" -t "${mp3Title}" -A 'Youtube-DL Rips' -c 'Ripped from Youtube via youtube-dl and encoded with ffmpeg on '"${ripDate}"' by alephalpha0 ([email protected]). Mors certa; vita incerta.' "${mp3File}"
# END MP3 TAGGING ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
##;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#exit 0
;;
3)
printLine
echo "Downloading youtube link into mp4 ::::::::::::::::::::"
youtube-dl --format "bestvideo+bestaudio[ext=m4a]/bestvideo+bestaudio/best" --merge-output-format mp4 "${file2dl}"
;;
*)
echo "What the actual fuck did you do man?!?! ::::::::::::::"
exit 1
;;
esac