dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

commit 0bc7056e394dbf093cea13e82aed50de992fe4b5
parent b333f76c6d180c36c00ba555c79d16b31eb5c038
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Wed,  8 Jun 2022 13:00:22 +0200

linkhandler: differentiate between bandcamp track and album

Diffstat:
Mscripts/linkhandler | 18+++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/scripts/linkhandler b/scripts/linkhandler @@ -70,9 +70,14 @@ sub checkstr { return scalar @result; } -sub is_bandcamp { +sub is_bandcamp_track { my $link = shift; - return checkstr($link, 'includes', ['bandcamp.com', 'godisanastronaut.com']); + return (checkstr($link, 'includes', ['bandcamp.com', 'godisanastronaut.com']) and checkstr($link, 'includes', ['/track/'])); +} + +sub is_bandcamp_album { + my $link = shift; + return (checkstr($link, 'includes', ['bandcamp.com', 'godisanastronaut.com']) and checkstr($link, 'includes', ['/album/'])); } sub is_video { @@ -231,7 +236,7 @@ sub download_video { } # Main {{{1 -if (is_bandcamp($LINK)) { +if (is_bandcamp_track($LINK)) { my @choices = ( ['Download', \&download_bandcamp], ['Play', sub { @@ -248,6 +253,13 @@ if (is_bandcamp($LINK)) { my $selected_ref = menu(\@choices); $selected_ref->($LINK); } +elsif (is_bandcamp_album($LINK)) { + my @choices = ( + ['Download', \&download_bandcamp] + ); + my $selected_ref = menu(\@choices); + $selected_ref->($LINK); +} elsif (is_video($LINK)) { my @choices = ( ['Play', sub {