Kodi Community Forum
Return the correct path to external players when in library mode - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Discussions (https://forum.kodi.tv/forumdisplay.php?fid=222)
+--- Forum: Feature Requests (https://forum.kodi.tv/forumdisplay.php?fid=9)
+--- Thread: Return the correct path to external players when in library mode (/showthread.php?tid=58910)



Return the correct path to external players when in library mode - ricelover - 2009-10-01

concerning http://www.xbmc.org/forum/showthread.php?p=411613&posted=1#post411613

the problem is that it is not possible to use an external player when in library mode because of the following issue:

when in library mode XBMC returns a musicdb-uri like
Quote:musicdb://3/411/5093.wma
which can't be used by external players

it would be nice if there i'll be some xml-tag or some new operator like {3}
for
Quote:playercorefactory.xml
which tells XBMC to return the correct path

The correct path can be computed by the following database query

Code:
SELECT path.strPath, song.strFileName from song,path where idSong=NUMBER RETURNED IN URI and path.idPath=song.idPath;

which in the above case would be:
Code:
SELECT path.strPath, song.strFileName from song,path where idSong=5093 and path.idPath=song.idPath;

this indieed returns the correct path which any external player should be able to use.
(for unix spaces need to be escaped with
Code:
\
of course)

the output of the above query is:

Quote:/media/LACIE/multimedia/audio/Eigene Musik/The Beatles/Anthology 1 Disc 2/19 You Know What to Do.wma

and as already stated this is indeed correct

EDIT as temporary hack until the suggested feature is implemented i wrote a little script which will do that:

Code:
DATABASE_URI="$1"
#TEST STRING WHEN     IN LIBRARY MODE: DATABASE_URI="/musicdb://3/411/5093.wma"
#TEST STRING WHEN NOT IN LIBRARY MODE: DATABASE_URI="/media/LACIE/multimedia/audio/Eigene Musik/The Beatles/Anthology 1 Disc 2/19 You Know What to Do.wma"

DATABASE_URI_PREFIX=`echo $DATABASE_URI | sed "s/:.*//g"`
if [ "/musicdb" = $DATABASE_URI_PREFIX ];
then
  echo "XBMC IN LIBRARY MODE"
  DATABASE_SONGID=`echo "$DATABASE_URI" | sed "s/\/.*\///" |  sed 's/\(.*\)\..*/\1/'`
  DATABASE_PATH="$HOME/.xbmc/userdata/Database/MyMusic7.db"
  totem "`sqlite3 -separator "" $DATABASE_PATH "SELECT path.strPath, song.strFileName from song,path where idSong=$DATABASE_SONGID and path.idPath=song.idPath;"`"
else
  echo "XBMC NOT IN LIBRARY MODE"
  totem "$DATABASE_URI"
fi

you may replace totem by any player you wanna use
cheers