Re: Add pre-scan task?
AF1 <AF1.ahzsio-NUepA2SMhDQqspMVqqL2D+4xXEVPTSb/[email protected]> Mon, 28 Mar 2022 10:21:51 +0000
| Newsgroups | gmane.music.equipment.slimdevices.devel |
|---|---|
| Organization | Logitech Squeezebox Forums |
| Message-ID | <[email protected]> |
mherger wrote:
> -f path/to/file
When I try to restore (values) from the backup file I think I have
encoding and un/escaping problems with special characters in the file
path that are driving me crazy. Maybe you'll spot what I'm missing:
Code:
--------------------
filename: "Evocação nº 1.m4a"
The url in LMS database saved as: file:///Users/af1/Music/MEDIA/05%20Evocac%CC%A7a%CC%83o%20n%C2%BA%201.m4a
FULL url saved in backup file (uri_escape_utf8): file%3A%2F%2F%2FUsers%2Faf1%2FMusic%2FMEDIA%2F05%2520Evocac%25CC%25A7a%25CC%2583o%2520n%25C2%25BA%25201.m4a
RELATIVE url in backup file (uri_escape_utf8): 05%2520Evocac%25CC%25A7a%25CC%2583o%2520n%25C2%25BA%25201.m4a
Media dir (as returned by LMS query (macOS)): /Users/af1/Music/MEDIA
--------------------
"-f" on the uri_unescaped *full* track url from the backup file works.
But the relative path, that I have to create first, won't work for this
file - probably because of the spec. chars because it works for less
problematic file names.
I just put the media dir followed by a slash before the relative url.
And then I've tried all kinds of variations before doing "-f" - which
never works for this file with the relative path (incl. fixpath):
Code:
--------------------
$fullTrackURL = uri_unescape($fullTrackURL);
$relTrackURL = uri_unescape($relTrackURL);
my $fullTrackPath = pathForItem($fullTrackURL);
if (-f $fullTrackPath) {
$log->info("found file at url \"$fullTrackPath\"");
$trackURL = $fullTrackURL;
} else {
$log->info("Couldn't find file for FULL trackURL. Will try with relative file url and current LMS media folders.");
my $lmsmusicdirs = getMusicDirs();
$log->debug('musicdirs = '.Dumper($lmsmusicdirs));
foreach (@{$lmsmusicdirs}) {
my $newFullTrackPath = $_."/".$relTrackURL;
$log->info("newFullTrackPath = \t\t\t".$newFullTrackPath);
#$newFullTrackPath = uri_unescape($newFullTrackPath);
#$log->info("newFullTrackPath UNESCAPED = \t".$newFullTrackPath);
$newFullTrackPath = Slim::Utils::Misc::fixPath($newFullTrackPath);
$log->info("newFullTrackPath FIXED = \t".$newFullTrackPath);
$newFullTrackPath = pathForItem($newFullTrackPath);
$log->info("newFullTrackPath AFTER pathForItem = \t".$newFullTrackPath);
if (-f $newFullTrackPath) {
$log->info("Found file at new url \"$newFullTrackPath\"");
$trackURL = Slim::Utils::Misc::fileURLFromPath($newFullTrackPath);
$log->info('New trackURL = '.$trackURL);
last;
} else {
$log->info("NOOOOOOOOOO... couldn't find new full track path!");
}
}
}
sub pathForItem {
my $item = shift;
if (Slim::Music::Info::isFileURL($item) && !Slim::Music::Info::isFragment($item)) {
return Slim::Utils::Misc::pathFromFileURL($item);
}
return $item;
}
--------------------
I'm in too deep right now to see the mistake. If you can spot it, please
let me know. FYI the code above is just a snapshot, I've tried with all
of the disabled lines at some point, all kinds of variations really,
just never the right one so far...
Thank you.
*Plugin repositories:* 'Ratings Light'
(https://github.com/AF-1/lms-ratingslight) 'Visual Statistics'
(https://github.com/AF-1/lms-visualstatistics) 'Use Comment Tag
Info' (https://github.com/AF-1/lms-usecommenttaginfo) 'Dynamic
Playlists 3 FAQ' (https://github.com/AF-1/lms-dynamicplaylists#faq)
'Custom Skip 3 FAQ' (https://github.com/AF-1/lms-customskip#faq)
------------------------------------------------------------------------
AF1's Profile: http://forums.slimdevices.com/member.php?userid=39306
View this thread: http://forums.slimdevices.com/showthread.php?t=116160
_______________________________________________
developers mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/developers