Getting started

155 views
Skip to first unread message

Steve Hancock

unread,
Jan 10, 2017, 4:08:41 AM1/10/17
to sonosp...@googlegroups.com
Hi guys,

I've been attempting to get sonospy up and running, but have been struggling a little. I run an Amahi server (based on Fedora), which I've been following the instructions for on the wiki, but to no avail. I'm somewhat of a novice when it comes to Linux, so it's entirely possible that I'm missing something obvious.

I have run the scan command (./scan.py -d Sonospy.db /var/hda/files/drives/data3/music/New\ Music > SonospyLoad.log) which produces a: scannumber: 7

Scannumber: 8

response. 

I then try to start the service (.sonospy_proxy -wSonospy=Sonospy,Sonospy.db)

This does not produce a response. From a little digging in this group, I have tried running a 'ps au' comand, which shows a python pycpoint command running, but says nothing about sonospy specifically. 

Nothing is showing up on my Sonos controller (Android), and I have set it to show media servers.

Any help would be much appreciated. Thank you.

Mark Henkelis

unread,
Jan 10, 2017, 1:49:20 PM1/10/17
to sonosp...@googlegroups.com
Hi,

Quite often a firewall blocks access to the appropriate ports on the PC you're running Sonospy on - did you follow the guidance on how to open those ports (or turned the firewall off for a test)?

Assuming you did, first of all let's check whether you got the service running correctly. You need to run sonospy_proxy from the base download folder (run an "ls sonospy_proxy" command to check you're in the right folder, you should see it listed in response to the command). Next check whether it is already running using:

    ps au

or

    ps -ef | grep pycpoint

Usually that shows something like (if it is running):

    mark      4006     1  1 18:34 pts/0    00:00:00 python pycpoint.py -p -wSonospy=Sonospy,Sonospy.db

If it's not running you obviously won't see that output. It's possible that your ps is not printing the arguments, or that when you ran the command the arguments didn't get passed.
If it is running then stop it first by running

    ./sonospy_stop

and check it has stopped with one of the ps commands. If it doesn't stop or you have multiple running, you'll have to use the kill command to get rid of them:

    kill -9 <pid>

where <pid> is the PID (process ID) from the ps command. Be careful here to get the right one(s).

When you start Sonospy the command includes a forward slash as the second character (you're telling Linux to look in the current folder with the ./ part), your example below didn't have that:

    ./sonospy_proxy -wSonospy=Sonospy,Sonospy.db

Once you've done this do another ps and see what it says - hopefully it will be like mine.

If nothing has changed from what you saw before, then stop Sonospy and start it a slightly different way:

    cd sonospy
    python pycpoint.py -p -wSonospy=Sonospy,Sonospy.db

That way the command prompt will return some messages, something like:

    Args:
    option.proxyonly: True
        WMP proxy: Sonospy=Sonospy,Sonospy.db
    Proxy. Name: Sonospy

Mark.
--
You received this message because you are subscribed to the Google Groups "Sonospy Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonospy-deve...@googlegroups.com.
To post to this group, send email to sonosp...@googlegroups.com.
Visit this group at https://groups.google.com/group/sonospy-devel.
For more options, visit https://groups.google.com/d/optout.

Steve Hancock

unread,
Jan 10, 2017, 5:23:31 PM1/10/17
to Sonospy Development
Hi Mark,

Thanks for your help so far. I seem to have come across an issue when starting up the service using your second command. The response I get is:

Args:
option.proxyonly: True
    WMP proxy: Sonospy=Sonospy,Sonospy.db
Proxy. Name: Sonospy
ERROR: Traceback (most recent call last):
  File "pycpoint.py", line 711, in __init__
    wmptype=wmptype, index_icons=self.index_icons)
  File "/home/steve/sonospy-msrefactor5/sonospy/proxy.py", line 191, in __init__
    raise ValueError(error)
ValueError: Unable to read track table (no such table: tracks)


Thanks again,
Steve

Mark Henkelis

unread,
Jan 10, 2017, 5:58:16 PM1/10/17
to sonosp...@googlegroups.com
Ok, that means that the database you have scanned into is empty, so your scan didn't work.

It's worth checking that the path you used to your music files is correct, and actually contains files. From your path it looks like you have a NAS mounted. What do you get with:

    ls /var/hda/files/drives/data3/music/New\ Music

You could scan to another database name and post the log output too.

Steve Hancock

unread,
Jan 11, 2017, 2:12:07 AM1/11/17
to Sonospy Development
The ls gives a list of the subfolders in the 'NewMusic' folder, so the path is correct. 

The log (I presume SonospyLoad.log?) shows the following after a showing a lot of tracks. I've kept the last track in so you can see how it reports the track scanning:

playlist track inserted: /var/hda/files/drives/data3/music/NewMusic/Talvin Singh/Talvin Singh - Ha (2001) [FLAC]/Talvin Singh - Ha.m3u : /var/hda/files/drives/data3/music/NewMusic/Talvin Singh/Talvin Singh - Ha (2001) [FLAC]/11 - Silver Flowers.flac
** EXITING on unhandled exception - See errors/ErrorDump-20170111-070355.txt
./gettags.py -d Sonospy.db /var/hda/files/drives/data3/music/NewMusic

I've had a look in the referenced error dump, which gives this:

  File "/usr/lib64/python2.7/codecs.py", line 699, in next
    return self.reader.next()
  File "/usr/lib64/python2.7/codecs.py", line 630, in next
    line = self.readline()
  File "/usr/lib64/python2.7/codecs.py", line 545, in readline
    data = self.read(readsize, firstline=True)
  File "/usr/lib64/python2.7/codecs.py", line 492, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xfa in position 0: invalid start byte

Mark Henkelis

unread,
Jan 11, 2017, 4:24:38 PM1/11/17
to sonosp...@googlegroups.com
It looks like a playlist file has invalid characters in it. This typically occurs when a file has been created on Windows, that contains foreign characters, and is moved to Linux - Windows is less concerned about file encodings usually. As the scan has errored, it won't have completed and post-processed the tracks it found (hence why you don't see a service).

Have a look in the log a little above the "playlist track inserted" line you showed, to see what playlist file it is complaining about. There are also log files in the log folder. You could then try editing the file with a Linux editor and fixing it (or just move it for now). If you post the file here I can run it myself and see if there's a more graceful way to flag the error than stopping on an exception.

Steve Hancock

unread,
Jan 11, 2017, 5:31:45 PM1/11/17
to Sonospy Development
Nice one Mark. I've now deleted all the unrequired playlist files from my folders, and the scan completed. I've also now started the service successfully.

Just a couple more things, if I may.

When starting the service, I get this:
Args:
option.proxyonly: True
    WMP proxy: Sonospy=Sonospy,Sonospy.db
Proxy. Name: Sonospy
/home/steve/sonospy-msrefactor5/sonospy/getalsa.sh: line 2: pactl: command not found

is that command not found message an issue?

Also, I can now see the service in my Sonos controller, but when using the controller search tool, it doesn't seem to search the sonospy database, only showing results from my music library and spotify account. Is this something that can be resolved, or is it a limitation of the system?

Thanks again

Mark Henkelis

unread,
Jan 11, 2017, 6:07:50 PM1/11/17
to sonosp...@googlegroups.com
Great, glad to head you've got it working.

The pactl command is used to find out which device to use for PulseAudio - that's only relevant if you want to play the sound output from the PC on Sonos. If it doesn't find the pactl command it ignores it - you wouldn't ordinarily see the error message if you started the service using sonospy_proxy (you can use that command again now rather than running using pycpoint).

Sonos doesn't support searching of a local media server. However, if you start your service using -s rather than -w (as a SMAPI service rather than a WMP server), search will work. You have to add the service to the controller using "Add Music Services" once you have started Sonospy. Using the SMAPI interface gives other advantages too :o)

Steve Hancock

unread,
Jan 12, 2017, 4:11:01 PM1/12/17
to Sonospy Development
I've now got everything up and running. Thanks for all your help, it's greatly appreciated.

Now that I've got the service running properly, is there a way to set an automatic scan of my database to run periodically?

Also, is there a way to show artwork for artists in the same way that album art is shown?

Mark Henkelis

unread,
Jan 12, 2017, 4:19:16 PM1/12/17
to sonosp...@googlegroups.com
You could use the cron command. I think one of the guys documented something, if you search this group you should find it.

Artist artwork isn't supported - Sonos didn't support it when I wrote the app, I'll have to check whether they've changed it. Do Sonos support it now?

Steve Hancock

unread,
Jan 12, 2017, 4:54:12 PM1/12/17
to Sonospy Development
While it doesn't appear to support it for standard libraries, it certainly does for music services like Spotify. I don't know how helpful that is.

Mark Henkelis

unread,
Jan 12, 2017, 5:28:03 PM1/12/17
to sonosp...@googlegroups.com
That's useful ta, I'll check.

Mark Henkelis

unread,
Jan 12, 2017, 6:35:13 PM1/12/17
to sonosp...@googlegroups.com
OK, so it's possible to display it, but Sonospy currently doesn't support capturing that it exists.

How would you intend to provide the artwork, and how would the scan know that it was artist artwork?


On 12/01/17 21:54, Steve Hancock wrote:

Steve Hancock

unread,
Jan 13, 2017, 2:43:54 AM1/13/17
to Sonospy Development
I'd imagine that depends on how people typically organise their libraries. Personally I have individual folders for each artist, which then contain folders for each album. If a 'folder.jpg' was able to be read from the artist folder, or an artist.jpg from the album folder, would that work?

MARK HENKELIS

unread,
Jan 13, 2017, 4:30:49 AM1/13/17
to sonosp...@googlegroups.com
The scanner doesn't know that it is an artist folder, it only finds tags from music files (it doesn't actually care where they are, the folder structure is incidental, the tags are the important bit). If there is artwork in the music file or the same folder, then it assumes it is album art. So there is no direct linkage between the folder name, the album name and the album art.

That said, I guess artist.jpg in the same location as the album art could work - with a rule to define which takes precedence if there are multiples across albums. We'd have to decide how to treat albums with multiple artists too, and albumartist vs artist.

We could also create a tag to point to the art, but that would require retagging.

There's also a capability to create external (text) tags file (for file types that don't support tagging), I could look at extending that, potentially changing it to support metadata (the interface allows text as well as images).

Another possibility is to create a utility to allow you to update the database, either from a form or a file - I guess that depends on how many artists you have.


From: "Steve Hancock" <stevem...@gmail.com>
To: "Sonospy Development" <sonosp...@googlegroups.com>
Sent: Friday, 13 January, 2017 7:43:53 AM
Subject: Re: [sonospy-devel] Getting started

Marc Schiffbauer

unread,
Jan 13, 2017, 8:26:40 AM1/13/17
to sonosp...@googlegroups.com
* MARK HENKELIS schrieb am 13.01.17 um 10:30 Uhr:
> The scanner doesn't know that it is an artist folder, it only finds
> tags from music files (it doesn't actually care where they are, the
> folder structure is incidental, the tags are the important bit). If
> there is artwork in the music file or the same folder, then it assumes
> it is album art. So there is no direct linkage between the folder
> name, the album name and the album art.
>
>
> That said, I guess artist.jpg in the same location as the album art
> could work - with a rule to define which takes precedence if there are
> multiples across albums. We'd have to decide how to treat albums with
> multiple artists too, and albumartist vs artist.

Why not look for a folder.jpg in the parent directory when a file
containing tags is found?

Maybe it would be helpful to introduce a new configurarion item like
"relative_artist_art_location" which takes a relative path.

Example values:

- ../folder.jpg (Parent folder of album directory)
- artist.jpg (Same folder as music file)

-Marc

Steve Hancock

unread,
Jan 13, 2017, 8:52:07 AM1/13/17
to sonosp...@googlegroups.com
Could you alternatively scan a separate folder containing artist images named to match the artist? For example Aphex Twin.jpg, Prince.jpg etc.

--
You received this message because you are subscribed to a topic in the Google Groups "Sonospy Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonospy-devel/jbLZ139gbQc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonospy-devel+unsubscribe@googlegroups.com.
To post to this group, send an email to sonosp...@googlegroups.com.

MARK HENKELIS

unread,
Jan 13, 2017, 12:03:33 PM1/13/17
to sonosp...@googlegroups.com
It's an option, but then the image name has to be an exact match for the artist name in the tags. I guess if I allow a separate scan for that (it ought not to change too much), you can always fix and re-scan.



From: "Steve Hancock" <stevem...@gmail.com>
To: sonosp...@googlegroups.com
Sent: Friday, 13 January, 2017 1:52:06 PM

Subject: Re: [sonospy-devel] Getting started

Could you alternatively scan a separate folder containing artist images named to match the artist? For example Aphex Twin.jpg, Prince.jpg etc.
On 13 Jan 2017 13:26, "Marc Schiffbauer" <ma...@schiffbauer.net> wrote:
* MARK HENKELIS schrieb am 13.01.17 um 10:30 Uhr:
> The scanner doesn't know that it is an artist folder, it only finds
> tags from music files (it doesn't actually care where they are, the
> folder structure is incidental, the tags are the important bit). If
> there is artwork in the music file or the same folder, then it assumes
> it is album art. So there is no direct linkage between the folder
> name, the album name and the album art.
>
>
> That said, I guess artist.jpg in the same location as the album art
> could work - with a rule to define which takes precedence if there are
> multiples across albums. We'd have to decide how to treat albums with
> multiple artists too, and albumartist vs artist.

Why not look for a folder.jpg in the parent directory when a file
containing tags is found?

Maybe it would be helpful to introduce a new configurarion item like
"relative_artist_art_location" which takes a relative path.

Example values:

- ../folder.jpg (Parent folder of album directory)
- artist.jpg (Same folder as music file)

-Marc

--
You received this message because you are subscribed to a topic in the Google Groups "Sonospy Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonospy-devel/jbLZ139gbQc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonospy-deve...@googlegroups.com.

To post to this group, send an email to sonosp...@googlegroups.com.
Visit this group at https://groups.google.com/group/sonospy-devel.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Sonospy Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonospy-deve...@googlegroups.com.
To post to this group, send email to sonosp...@googlegroups.com.

Steve Hancock

unread,
Jan 13, 2017, 12:19:22 PM1/13/17
to Sonospy Development
Whatever is best for you. That method would remove the issue with various artist compilation albums that would come up with the other method. Either way, I'd just be delighted to have some lovely artist art on my system! 

per...@gmail.com

unread,
Jan 13, 2017, 1:16:38 PM1/13/17
to Sonospy Development
Hi there. The cron stuff was probably me. See steps 13-15 in this documentation file I wrote a while back for installing on a Pi and NAS

Martin
Sonospy_Raspberry Pi v02.docx

Steve Hancock

unread,
Jan 13, 2017, 1:19:57 PM1/13/17
to sonosp...@googlegroups.com
Thanks Martin

You received this message because you are subscribed to a topic in the Google Groups "Sonospy Development" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonospy-devel/jbLZ139gbQc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonospy-devel+unsubscribe@googlegroups.com.

Steve Hancock

unread,
Jan 13, 2017, 5:55:27 PM1/13/17
to Sonospy Development
Just another quick question regarding contributing artists. It's probably easiest to explain with an example.

(hed) Planet Earth have an album which features Serj Tankian on one track. I have tagged that track's contributing artist field with 'Serj Tankian; (hed) Planet Earth', however in the sonos controller, when I click on the Serj Tankian artist in contributing Artists, it shows all of the tracks on the album, rather than just the one he has appeared on. Is there a way around this, or is it a limitation of the system?

Mark Henkelis

unread,
Jan 13, 2017, 7:21:51 PM1/13/17
to sonosp...@googlegroups.com
I've just done a quick test, and mine worked ok.

Which actual tag values are you using - I'm guessing artist and albumartist, but which way round?

pycpoint.ini lets you adjust what is displayed in what index:

    # You can choose whether the artist index contains entries from the
    # artist or albumartist tags in your data (note that the contributing
    # artist index will contain entries from your artist tags). If you want
    # to show albumartist tags, set use_albumartist to Y

    use_albumartist=Y

    # You can choose how to group tracks into albums. If you want all
    # tracks from an album to be together regardless of albumartist, set
    # album_identification to album. If you want separate albums for
    # separate artists, set it to album,albumartist.

    album_identification=album
    #album_identification=album,albumartist

Also note that the semi-colon in tags is treated as a separator by default - use multiple_tag_separator in scan.ini to change it.

Steve Hancock

unread,
Jan 14, 2017, 6:36:13 AM1/14/17
to Sonospy Development
I'm using '(hed) Planet Earth' as albumartist and '(hed) Planet Earth; Serj Tankian; Morgan Lander' as artist.

I've tried changing options in the index, but whichever way I set things, the contributing artist index for Serj Tankian always shows the whole album, rather than just the track that he features on.  
Thanks Martin

To unsubscribe from this group and all its topics, send an email to sonospy-deve...@googlegroups.com.

To post to this group, send email to sonosp...@googlegroups.com.
Visit this group at https://groups.google.com/group/sonospy-devel.
For more options, visit https://groups.google.com/d/optout.

Mark Henkelis

unread,
Jan 14, 2017, 6:58:06 AM1/14/17
to sonosp...@googlegroups.com
Are you using WMP (-w) or SMAPI (-s)?

I'm guessing you did a rescan after you changed the tags?

Mark Henkelis

unread,
Jan 14, 2017, 7:23:37 AM1/14/17
to sonosp...@googlegroups.com
I've just set up a test to mimic yours, and get the correct behavior with both WMP and SMAPI interfaces. My ini settings are:

use_albumartist=Y
album_identification=album
show_separate_albums=N

I can send you a program to extract from your database so I can recreate it at this end to see how the tags were extracted.

Steve Hancock

unread,
Jan 14, 2017, 4:06:12 PM1/14/17
to Sonospy Development
I'm using SMAPI and have those same settings. I'd be happy to send you anything you need, so feel free to send the program.

Mark Henkelis

unread,
Jan 14, 2017, 4:47:06 PM1/14/17
to sonosp...@googlegroups.com
There's a script called export.sh in the databaseupdates folder. If you run that and pass your database path/name as a parameter, it will extract the tags and zip them up (into a file called db.zip).

If you send that to my email address (mark . henkelis @ tesco . net, without the spaces), I'll have a look.
--

Steve Hancock

unread,
Jan 15, 2017, 3:20:37 AM1/15/17
to Sonospy Development
The only things in my databaseupdates folder are dumpdb.py, update1.sh and update2.sh.
Thanks Martin



On Tuesday, 10 January 2017 22:58:16 UTC, Mark Henkelis wrote: <blockquote class="gmail_quote"

Mark Henkelis

unread,
Jan 15, 2017, 6:41:10 AM1/15/17
to sonosp...@googlegroups.com
My mistake, I haven't added that script to the repo. You can use the Python script instead:

    python dumpdb.py <database>

That will create a file called dump.txt.gz.
--

Steve Hancock

unread,
Jan 15, 2017, 7:26:49 AM1/15/17
to Sonospy Development
On running that script, I get this response:

Database: Sonospy.db
Can't access Sonospy.db

Mark Henkelis

unread,
Jan 15, 2017, 8:53:09 AM1/15/17
to sonosp...@googlegroups.com
You'll have to give the path to the database if you're running the script from the databaseupdates folder.
Reply all
Reply to author
Forward
0 new messages