diff options
author | 2014-08-10 19:41:41 -0400 | |
---|---|---|
committer | 2014-08-10 19:41:41 -0400 | |
commit | f1e00951f63022aab1dabb5b82c11de5d1e70b15 (patch) | |
tree | f742f790a6afb0ab07417df86cf86620ce90bec8 | |
parent | 70892f0bde72d777451510c11be845a8f201bbd2 (diff) | |
parent | da801d4e550ef6f5b4a2c1e35daff4d036749deb (diff) |
Merge branch 'master' of ssh://git-annex.branchable.com
-rw-r--r-- | doc/tips/dumb_metadata_extraction_from_xbmc.mdwn | 15 | ||||
-rw-r--r-- | doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl | 24 |
2 files changed, 39 insertions, 0 deletions
diff --git a/doc/tips/dumb_metadata_extraction_from_xbmc.mdwn b/doc/tips/dumb_metadata_extraction_from_xbmc.mdwn new file mode 100644 index 000000000..a96fe273f --- /dev/null +++ b/doc/tips/dumb_metadata_extraction_from_xbmc.mdwn @@ -0,0 +1,15 @@ +I wanted to get the list of movies I haven't seen yet in XBMC, and i'm lazy. So I'll use [[metadata]] to be able to extract those movies only, for the road for example. + +First I fiddled around with shell scripts to extract the list of those films, which in XBMC-speak means that have a `NULL playCount`. Since there are two ways that XMBC can represent those files (in a `stack://` if there is multiple files for the movie or not), there are two scripts. For "stacked" movies: + + echo 'SELECT files.strFileName FROM movie JOIN files ON files.idFile=movie.idFile JOIN path ON path.idPath=files.idPath WHERE playCount IS NULL AND files.strFileName LIKE "stack://%";' | sqlite3 /home/video/.xbmc/userdata/Database/MyVideos75.db | sed "s#stack://##;s/, /\n/g" | sed "s#/home/media/video/##" + +And the rest: + + echo 'SELECT path.strPath || files.strFileName FROM movie JOIN files ON files.idFile=movie.idFile JOIN path ON path.idPath=files.idPath WHERE playCount IS NULL AND files.strFileName NOT LIKE "stack://%";' | sqlite3 /home/video/.xbmc/userdata/Database/MyVideos75.db | sed "s#/home/media/video/##" + +Also notice how I remove the absolute prefix for the annex so that i can refer to files as a relative path. + +So this quick and dirty hack could have been used to mark files as "new". Unfortunately, this won't unmark them when the playcount increases. So instead I think this should be a field, and we need to extract the playcount. Play around with shell scripting enough to get sick, get back into bad perl habits and you'll end up with this nasty script: [[git-annex-xbmc-playcount.pl]]. + +-- [[anarcat]] 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 new file mode 100644 index 000000000..1fa7f0baa --- /dev/null +++ b/doc/tips/dumb_metadata_extraction_from_xbmc/git-annex-xbmc-playcount.pl @@ -0,0 +1,24 @@ +#! /usr/bin/perl -w + +my $dbpath="/home/video/.xbmc/userdata/Database/MyVideos75.db"; +my $prefix="/home/media/video/"; + +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) { + my ($count, $dir, $file) = split /\|/; + chomp $file; + $dir =~ s/$prefix//; + if ($file =~ s#stack://##) { + for (split /,/, $file) { + s/$prefix//; + s/^ //; + s/ $//; + my @cmd = (qw(git annex metadata --set), "playCount=$count", $_); + system(@cmd); + } + } + else { + my @cmd = (qw(git annex metadata --set), "playCount=$count", "$dir$file"); + system(@cmd); + } +} |