mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-22 05:39:48 +00:00
Add feature: Download selected track
This commit is contained in:
parent
431ce8e1a5
commit
31770dfe37
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
tags_db
|
tags_db
|
||||||
|
music_dl
|
||||||
playlist.m3u8
|
playlist.m3u8
|
||||||
preload
|
preload
|
||||||
instance.hist
|
instance.hist
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"instance": "sound.redeyes.club",
|
"instance": "sound.redeyes.club",
|
||||||
|
"download_selected_track": false,
|
||||||
"tags": [
|
"tags": [
|
||||||
"8bit",
|
"8bit",
|
||||||
"Alternative",
|
"Alternative",
|
||||||
|
@ -5,6 +5,7 @@ instance_hist='instance.hist'
|
|||||||
ordering='title'
|
ordering='title'
|
||||||
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
|
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
|
||||||
instance_point="https://$instance/api/v1"
|
instance_point="https://$instance/api/v1"
|
||||||
|
download_selected_track=$(jj -i config.json download_selected_track)
|
||||||
|
|
||||||
touch .auth.json
|
touch .auth.json
|
||||||
chmod 600 .auth.json
|
chmod 600 .auth.json
|
||||||
@ -60,6 +61,26 @@ funkwhale_api_get_tracks()
|
|||||||
2>&1 | tee preload
|
2>&1 | tee preload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
play_or_download_selected()
|
||||||
|
{
|
||||||
|
mkdir -p music_dl
|
||||||
|
if [ -n "$auth" ]; then
|
||||||
|
if [ "$download_selected_track" = 'true' ]; then
|
||||||
|
default_curl_opt --tcp-fastopen --output - --url "https://$instance$download_track&token=$listen_token" | \
|
||||||
|
tee "music_dl/$artist_name - $title.$download_ext" | $default_player_command -
|
||||||
|
else
|
||||||
|
$default_player_command "https://$instance$play_track?token=$listen_token"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$download_selected_track" = 'true' ]; then
|
||||||
|
default_curl_opt --tcp-fastopen --output - --url "https://$instance$download_track" | \
|
||||||
|
tee "music_dl/$artist_name - $title.$download_ext" | $default_player_command -
|
||||||
|
else
|
||||||
|
$default_player_command "https://$instance$play_track"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
funkwhale_menu_tracks()
|
funkwhale_menu_tracks()
|
||||||
{
|
{
|
||||||
sub2_menu=1
|
sub2_menu=1
|
||||||
@ -105,11 +126,12 @@ funkwhale_menu_tracks()
|
|||||||
*)
|
*)
|
||||||
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
||||||
play_track=$(jj -i preload results.$index.listen_url)
|
play_track=$(jj -i preload results.$index.listen_url)
|
||||||
if [ -n "$auth" ]; then
|
download_track=$(jj -i preload results.$index.uploads.0.listen_url)
|
||||||
$default_player_command "https://$instance$play_track?token=$listen_token"
|
download_ext=$(jj -i preload results.$index.uploads.0.extension)
|
||||||
else
|
title=$(jj -i preload results.$index.title)
|
||||||
$default_player_command "https://$instance$play_track"
|
artist_name=$(jj -i preload results.$index.artist.name)
|
||||||
fi ;;
|
play_or_download_selected
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user