Compare commits
No commits in common. "e8b1330809b2b9354b9cbf37715b085377f8c1b7" and "e509fce91dea898c33419752181fcebe6ee5bb64" have entirely different histories.
e8b1330809
...
e509fce91d
3 changed files with 27 additions and 30 deletions
|
@ -31,10 +31,6 @@ USERAGENT = (
|
||||||
|
|
||||||
LYRICS_ROW = '.main-page>.row>.col-xs-12'
|
LYRICS_ROW = '.main-page>.row>.col-xs-12'
|
||||||
|
|
||||||
safename_re = re.compile(
|
|
||||||
r'[^A-Za-z0-9А-ЯЁа-яё \'".,()\[\]&!#$@_~=*+-]'
|
|
||||||
)
|
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
session.headers['User-Agent'] = USERAGENT
|
session.headers['User-Agent'] = USERAGENT
|
||||||
|
|
||||||
|
@ -99,11 +95,6 @@ def input_num(msg: str, def_: int = 0) -> int:
|
||||||
return def_
|
return def_
|
||||||
|
|
||||||
|
|
||||||
def safename(value: str) -> str:
|
|
||||||
|
|
||||||
return safename_re.sub(' ', value)
|
|
||||||
|
|
||||||
|
|
||||||
def conv_title(file: str) -> str:
|
def conv_title(file: str) -> str:
|
||||||
|
|
||||||
# Remove file path
|
# Remove file path
|
||||||
|
@ -367,12 +358,12 @@ def tagmp3(
|
||||||
|
|
||||||
newdir = (
|
newdir = (
|
||||||
Path('./tagged') /
|
Path('./tagged') /
|
||||||
safename(parsed['artist']) /
|
parsed['artist'] /
|
||||||
safename(parsed['album'])
|
parsed['album']
|
||||||
)
|
)
|
||||||
os.makedirs(newdir, exist_ok=True)
|
os.makedirs(newdir, exist_ok=True)
|
||||||
|
|
||||||
newpath = newdir / safename(
|
newpath = newdir / (
|
||||||
f"{parsed['track_no']}. " +
|
f"{parsed['track_no']}. " +
|
||||||
f"{parsed['title']}.mp3"
|
f"{parsed['title']}.mp3"
|
||||||
)
|
)
|
||||||
|
|
37
autoytdlp.sh
37
autoytdlp.sh
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
debug=1
|
debug=0
|
||||||
watching=1
|
watching=1
|
||||||
links=()
|
links=()
|
||||||
success=0
|
success=0
|
||||||
|
@ -30,7 +30,7 @@ ytlink () {
|
||||||
}
|
}
|
||||||
|
|
||||||
safename () {
|
safename () {
|
||||||
safe="${1//[^A-Za-z0-9А-ЯЁа-яё ().,_-]/_}"
|
safe="${1//[^A-Za-z0-9А-Яа-я ().,_-]/}"
|
||||||
echo "${safe// /_}" | sed -E 's/_+/_/'
|
echo "${safe// /_}" | sed -E 's/_+/_/'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +43,6 @@ bold () {
|
||||||
|
|
||||||
dlwith_piped () {
|
dlwith_piped () {
|
||||||
|
|
||||||
bold 'Enter Piped API instance URL'
|
|
||||||
bold '(ytapi.dc09.ru is used by default)'
|
|
||||||
read -r pipedurl
|
|
||||||
pipedurl="${pipedurl:-ytapi.dc09.ru}"
|
|
||||||
pipedurl=$(echo "$pipedurl" | sed -E 's#https?://##')
|
|
||||||
|
|
||||||
bold 'Choose the type of stream: 1.audio or 2.video'
|
bold 'Choose the type of stream: 1.audio or 2.video'
|
||||||
read -r stream_num
|
read -r stream_num
|
||||||
if [[ $stream_num == 1 ]]; then
|
if [[ $stream_num == 1 ]]; then
|
||||||
|
@ -62,10 +56,15 @@ dlwith_piped () {
|
||||||
jqexpr=".${stream}Streams|map(select(.videoOnly==false))|max_by(${maxby})"
|
jqexpr=".${stream}Streams|map(select(.videoOnly==false))|max_by(${maxby})"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
bold 'Here is an expression for JQ utility'
|
bold 'Here is an expression for JQ utility.'
|
||||||
echo 'Correct it or just press Enter'
|
echo 'Press Enter to leave it intact, or type another expression.'
|
||||||
read -e -r -i "$jqexpr" newexpr
|
echo "$jqexpr"
|
||||||
jqexpr="${newexpr:-$jqexpr}"
|
read -r newexpr
|
||||||
|
if [[ $newexpr == "" ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
jqexpr="$newexpr"
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
bold 'Started'
|
bold 'Started'
|
||||||
|
@ -83,7 +82,7 @@ dlwith_piped () {
|
||||||
echo "Found YT video ID: $video_id"
|
echo "Found YT video ID: $video_id"
|
||||||
|
|
||||||
echo "Requesting URL for $link"
|
echo "Requesting URL for $link"
|
||||||
video_obj=$(curl -sL "https://$pipedurl/streams/$video_id")
|
video_obj=$(curl -sL "https://ytapi.dc09.ru/streams/$video_id")
|
||||||
|
|
||||||
stream_obj=$(echo "$video_obj" | jq "$jqexpr")
|
stream_obj=$(echo "$video_obj" | jq "$jqexpr")
|
||||||
stream_url=$(echo "$stream_obj" | jq ".url" | sed s/^\"// | sed s/\"$//)
|
stream_url=$(echo "$stream_obj" | jq ".url" | sed s/^\"// | sed s/\"$//)
|
||||||
|
@ -136,10 +135,14 @@ dlwith_ytdlp () {
|
||||||
echo 'Use "b" without quotes for video and audio'
|
echo 'Use "b" without quotes for video and audio'
|
||||||
echo ' "bv" to download only video'
|
echo ' "bv" to download only video'
|
||||||
echo ' "ba" to download only audio'
|
echo ' "ba" to download only audio'
|
||||||
echo 'Defaults to "b" if an empty string is passed'
|
echo 'details: https://github.com/yt-dlp/yt-dlp#format-selection'
|
||||||
echo 'Details: https://github.com/yt-dlp/yt-dlp#format-selection'
|
read -r format
|
||||||
read -e -r format
|
|
||||||
format="${format:-b}"
|
if [[ $format == "" ]]; then
|
||||||
|
echo 'Passed an empty string,'
|
||||||
|
echo 'using "b" as default.'
|
||||||
|
format="b"
|
||||||
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
bold 'Started'
|
bold 'Started'
|
||||||
|
|
|
@ -6,7 +6,10 @@ mkdir -p ./convert
|
||||||
echo "Enter input files extension:"
|
echo "Enter input files extension:"
|
||||||
echo "(empty string to match all)"
|
echo "(empty string to match all)"
|
||||||
read -r ext_input
|
read -r ext_input
|
||||||
ext_input="${ext_input:-*}"
|
|
||||||
|
if [[ $ext_input == "" ]]; then
|
||||||
|
ext_input="*"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Enter output files extension:"
|
echo "Enter output files extension:"
|
||||||
echo "(must not be empty)"
|
echo "(must not be empty)"
|
||||||
|
|
Reference in a new issue