diff options
author | 2014-10-01 02:19:53 +0000 | |
---|---|---|
committer | 2014-10-01 02:19:53 +0000 | |
commit | 75f12adda381d62a8245d9f0ca555e130c516b77 (patch) | |
tree | ea8970fa3b84397c79790a10879ba9d5b23eea21 /doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl | |
parent | 2ff959d45a6e85dffb071e414b5491e77fcde2f5 (diff) |
auto-detect xbmc library location, clarify
Diffstat (limited to 'doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl')
-rw-r--r-- | doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl b/doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl index 76ad33649..3e2bd9bce 100644 --- a/doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl +++ b/doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl @@ -1,7 +1,24 @@ #! /usr/bin/perl -w -my $dbpath="/home/video/.xbmc/userdata/Database/MyVideos75.db"; +# we want to operate on relative links, so set this to the common prefix +# to the git annex repo my $prefix="/home/media/video/"; +# this is the directory for the XBMC database +my $path = '/home/video/.xbmc/userdata/Database/'; + +# no user-serviceable parts below + +# list videos database, find the latest one +# modified version of +# http://stackoverflow.com/questions/4651092/getting-the-list-of-files-sorted-by-modification-date-in-perl +opendir my($dirh), $path or die "can't opendir $path: $!"; +my @flist = sort { -M $a <=> -M $b } # Sort by modification time + map { "$path/$_" } # We need full paths for sorting + grep { /^MyVideos.*\.db$/ } + readdir $dirh; +closedir $dirh; + +my $dbpath=$flist[0]; my @lines = `echo 'SELECT playCount, path.strPath, files.strFileName FROM movie JOIN files ON files.idFile=movie.idFile JOIN path ON path.idPath=files.idPath;' | sqlite3 $dbpath`; for (@lines) { @@ -11,7 +28,6 @@ for (@lines) { if ($count !~ /[0-9]/) { $count = 0; } - $dir =~ s/$prefix//; if ($file =~ s#stack://##) { for (split /,/, $file) { s/$prefix//; @@ -22,6 +38,7 @@ for (@lines) { } } else { + $dir =~ s/$prefix//; my @cmd = (qw(git annex metadata --set), "playCount=$count", "$dir$file"); system(@cmd); } |