rickyphewitt / emby-skill

This skill allows audio playback from an emby server
11 stars 19 forks source link

Unable to get Emby skill to play Artist or Album based songs #36

Closed brianread108 closed 5 years ago

brianread108 commented 5 years ago

I have picroft setup with an emby server running also on my network. I can get a single song played, but the "album" and "artist" search terms do not return anything (and the skill tells me that it is playing a "mix" but plays nothing) and the logs show a zero return from emby.

If I "search" for something which is common among songs then the logs show a result of more than one but the skill just plays one of the them (the first I guess). As no-one else has reported these sort of problems I am imagining that perhaps my emby server is not setup correctly. It is running in a linux debian stretch container under proxmox, and browser and smart tv access works to it.

Actually it is doing the "mix" job and giving me multiple songs when I ask for one however the Artist and Album modes are not working at all.
brianread108 commented 5 years ago

Here is what I get when I try to play an Album:

~~~~by - INFO - {'utterance': 'play album abbey road from mb', 'media': 'album abbey road'}
10:23:37.439 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=album abbey road
10:23:37.517 - emby_rickyphewitt.emby_croft - INFO - []
~~~~by_rickyphewitt.emby_croft - INFO - Found 0 item(s) when searching for album abbey road
~~~~by - INFO - {'utterance': 'play album abbey road from mb', 'media': 'album abbey road'}
10:33:49.053 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=album abbey road
10:33:49.081 - emby_rickyphewitt.emby_croft - INFO - []

```~~~~by_rickyphewitt.emby_croft - INFO - Found 0 item(s) when searching for album abbey road

However it tells me it is playing "album abbey road mix" but plays nothing.

I can play the album from the browser connected to Emby sucessfully. The search for "abbey road" works fine.

I can also play "Something" (the first track) by saying "Play something from mb" on picroft:

0:38:50.574 - Emby - INFO - {'utterance': 'play something from mb', 'media': 'something'}
10:38:50.575 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=something
~~~~tem object at 0x597b2710>, <emby_rickyphewitt.emby_client.EmbyMediaItem object at 0x597b2150>]
10:38:50.633 - emby_rickyphewitt.emby_croft - INFO - Found 2 item(s) when searching for something
rickyphewitt commented 5 years ago

@brianread108

It looks like there are 2 different issues based on the logs. For the 1st one it appears that mycroft is not understanding that you want to play an album 'abbey road' instead of the default instant mix.

The second issue where only a single track is playing should be the same as if you went to the 'something' item from the emby web ui and clicked 'Instant Mix'. After an item is found the skill just asks Emby for an instant mix of that item.

So a few things that may help:

I've also created an issue to update this skill in the mycroft repo: #37

Let me know the results after the update and if an instant mix of 'something' plays more than one song via the web ui.

Thanks!

brianread108 commented 5 years ago

I am running Emby 4.2.1.0.

Have now removed the old Emby skill and installed it direct from your repo.

However I am still getting the failure on the Album request. Can I check somewhere that I now have the correct emby skill?

An instant mix of "something" on the web browser does not play more than one title.

rickyphewitt commented 5 years ago

If you can provide additional logs when attempting to play an artist/album specifically that should show us if the version you are running is up to date.

And the instant mix of "something" appears to be doing what the web browser is. This mostly happens when the metadata on "something" is incomplete/incorrect/missing. While I don't know exactly how the instant mix works behind the scenes in emby it does attempt to play similar items based on metadata. So the fix to this problem is around the metadata in emby itself vs the skill.

On another note I have wanted to add an 'autoplay' or 'continous play' mode where when the queue is empty music is automatically added.

brianread108 commented 5 years ago

The logs look the same as they did before - which makes me wonder if I've really managed to update sucessfully.

I did "msm remove emby" and then "msm install https://github.com/rickyphewitt/emby-skill.git"

was that correct?

I tried it again:

(.venv) pi@mycroft:~ $ mycroft-stop
Stopping all mycroft-core services
Stopping messagebus.service (663)...stopped.
Stopping skills (666)...failed to stop.
  Killing skills (666)...killed.
Stopping audio (669)...stopped.
Stopping speech (672)...stopped.
Stopping enclosure (675)...failed to stop.
  Killing enclosure (675)...killed.
(.venv) pi@mycroft:~ $ msm list | grep emby
emby    [installed]
(.venv) pi@mycroft:~ $ msm remove emby
INFO - Best match (1.0): emby by rickyphewitt
INFO - Successfully removed emby
(.venv) pi@mycroft:~ $ msm list | grep emby
emby
(.venv) pi@mycroft:~ $ msm install https://github.com/rickyphewitt/emby-skill.git
INFO - Downloading skill: https://github.com/rickyphewitt/emby-skill
INFO - Installing system requirements...
INFO - Installing requirements.txt for emby
INFO - Successfully installed emby
(.venv) pi@mycroft:~ $ msm list | grep emby
emby    [installed]
(.venv) pi@mycroft:~ $ 

I then find that it tells me that the config is wrong and I have to reboot the pi.

then I get this when I try the album:

07:14:03.777 - Emby - INFO - {'utterance': 'play album abbey road from mb', 'media': 'album abbey road'}
07:14:03.778 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=album abbey road
07:14:03.806 - emby_rickyphewitt.emby_croft - INFO - []
07:14:03.807 - emby_rickyphewitt.emby_croft - INFO - Found 0 item(s) when searching for album abbey road
brianread108 commented 5 years ago

More details - I've compared the contents of ~mycroft-core/skills/emby.rickyphewitt/emby_client.py and the equivalent one in your git repo and clearly, the one in the picroft system is an earlier version (without for example the "def get_albums_by_artist" in it). The date and time on the file is when I updated the skill as above.

I am at a loss to understand how it has not been updated, given what I did above.

Clearly I could force it to be correct by downloading the git data specifically and then copying it to the mycroft directories, however it seems to me this is worth pursuing a bit longer..

rickyphewitt commented 5 years ago

I don't understand why the skill didn't update as expected. It looks like it does from the logs and that is exactly the commands to run based on the docs. The mycroft community should be able to help more with the upgrade issue: https://community.mycroft.ai/. Alternatively you can install a custom skill via the https://account.mycroft.ai/skills page. There is a Custom Skill where you can paste in the repo URL.

I'm also actively working on an update to the skill so it is the correct version in the mycroft skills repo. Though this may take a week or so based on how much time I can put toward it.

brianread108 commented 5 years ago

I am finally getting the "latest" emby skill now. However I am now getting program failures, which I am guessing are due to your work on it? Here's an example:

19:18:51.579 - Emby - INFO - {'media': 'someone', 'utterance': 'play someone from mb'}
19:18:51.581 - Emby - INFO - 'NoneType' object has no attribute 'instant_mix_for_media'

I'll go back to the official version for now and look out for the update. Ultimately I'd like to help (I am programmer) as this skill is important to me.

rickyphewitt commented 5 years ago

@brianread108,

I would love additional help on this skill! I don't understand why you received the above error. There are usually more logs involved where we may be able to see if it found any items. I'm currently on master with my mycroft and when I request to play something I know is not found I get the below:

06:12:29.142 - Emby - INFO - {'media': 'supercalifragilisticexpialidocious', 'utterance': 'play supercalifragilisticexpialidocious from mb'}
06:12:30.265 - emby-skill.emby_client - INFO - ?SearchTerm=supercalifragilisticexpialidocious
06:12:30.289 - Emby - INFO - No songs Returned

If you'd like to experiment more you can always install mycroft on a linux box and add/remove skills there. I do that for my local development then install the skill to my mycroft when I'm happy with it. This link has more info setting up the dev environment: https://mycroft.ai/documentation/skills/introduction-developing-skills/

I really wish there were line numbers in the failures :disappointed: would make triage much easier.

brianread108 commented 5 years ago
I'll do that. Nothing from me for a week or so - back in the office beginning of September.
rickyphewitt commented 5 years ago

Sounds good! and if there is anything I can do to help let me know. I'm still working on updating tests to submit the updated skill into mycroft-skills repo.

rickyphewitt commented 5 years ago

@brianread108,

I've posted a request for feedback in the mycroft community to get the current master branch into the skills repo. If you get a chance to test and provide feedback: https://community.mycroft.ai/t/emby-music-skill-update-testing-and-feedback/7122

brianread108 commented 5 years ago

I am still going round in circles here...I remade my picroft from the latest image and then installed your skill direct from your github using msm. After a lot of trying I discovered that it only will accept an Ip address for the me3dia server, not a symbolic name (despite it being resolvable on the pi).

I can now play as before, here is the logs:

14:07:59.188 - mycroft.skills.core:load_skill:122 - INFO - ATTEMPTING TO LOAD SKILL: emby.rickyphewitt with ID emby.rickyphewitt
14:07:59.358 - mycroft.skills.core:load_skill:151 - INFO - Loaded emby.rickyphewitt
14:08:40.624 - Emby - INFO - {'media': 'something', 'utterance': 'play something from mb'}
14:08:40.632 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=something
14:08:40.717 - emby_rickyphewitt.emby_croft - INFO - [<emby_rickyphewitt.emby_client.EmbyMediaItem object at 0x6c942790>, <emby_rickyphewitt.emby_client.EmbyMediaItem object at 0x6c942810>]
14:08:40.718 - emby_rickyphewitt.emby_croft - INFO - Found 2 item(s) when searching for something
14:09:18.211 - Emby - INFO - {'media': 'artist beatles', 'utterance': 'play artist beatles from mb'}
14:09:18.213 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=artist beatles
14:09:18.261 - emby_rickyphewitt.emby_croft - INFO - []
14:09:18.269 - emby_rickyphewitt.emby_croft - INFO - Found 0 item(s) when searching for artist beatles

As you can see it is still not seeing the "artist". I am testing by typing the command in on the cli, as that seems more reliable (my microphone has trouble with "emby or mb" unless I am very careful. Maybe my Southern English)

It looks to me as though the version has dropped back to the one in the skills repo despite me not installing it at all from that repo. Looking at /opt/skills/emby.rickyphewitt/init.py seems to be the release version. "msm remove emby" has deleted that directory. Installed again from github but the version does not seem to be the one from your github.

Maybe its cached somewhere?

I am at a loss to know how to test your latest version.

I am loth the install on my fedora 30 desktop I tried on a Virtual Box VM (using fedora server 30), but could not get the speaker and microphone to be passed through.

brianread108 commented 5 years ago

Done some more investigation:

A new install of picroft on a raspberry pi B+:


(.venv) pi@mycroft:~ $ msm install https://github.com/rickyphewitt/emby-skill 
INFO - Downloading skill: https://github.com/rickyphewitt/emby-skill
INFO - Installing system requirements...
INFO - Installing requirements.txt for emby
INFO - Successfully installed emby

then

(.venv) pi@mycroft:~ $ cat /opt/mycroft/skills/emby.rickyphewitt/emby_client.py | grep -i artist
ARTIST_INSTANT_MIX_URL = "/Artists/InstantMix"
    ARTIST = "MusicArtist"
(.venv) pi@mycroft:~ $ 

when I download your github onto my desktop:

[brianr@bjrfeddesktop emby-skill-master]$ cat emby_client.py | grep -i artist
ARTIST_INSTANT_MIX_URL = "/Artists/InstantMix"
ITEMS_ARTIST_KEY = "ArtistIds"
ITEMS_ALBUMS_URL = ITEMS_URL + "/?SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=MusicAlbum&Recursive=true&" + ITEMS_ARTIST_KEY + "="
ITEMS_SONGS_BY_ARTIST_URL = ITEMS_URL + "/?SortBy=SortName&SortOrder=Ascending&IncludeItemTypes=Audio&Recursive=true&" + ITEMS_ARTIST_KEY + "="
    def get_albums_by_artist(self, artist_id):
        url = ITEMS_ALBUMS_URL + str(artist_id)
    def get_songs_by_artist(self, artist_id, limit=None):
        url = ITEMS_SONGS_BY_ARTIST_URL + str(artist_id)
    ARTIST = "MusicArtist"
[brianr@bjrfeddesktop emby-skill-master]$ BB

I'll cross post this onto the mycroft forum and see if they have any ideas.

https://community.mycroft.ai/t/unable-to-install-emby-skill-direct-from-github-repo/7171

brianread108 commented 5 years ago

ok, found the problem - the msm install needs the -l parameter. msm -l install https://github.com/rickyphewitt/emby-skill

rickyphewitt commented 5 years ago

Yep. :face_with_head_bandage: I hadn't realized that was needed. I"m hoping that this resolves the issue and you are able to use the updated version. Also I am able to use a dns name to my emby server vs an IP so we may want to look into that issue however we should open up a new issue so as not to convolute this one. I'll keep this open for a bit longer if you run into other issues.

brianread108 commented 5 years ago

Am trying things out as we speak! Have already noticed that the "album" and "Artist" only work if you specify "from mb".

Also if the search for artist, album or song name returns more than one (object?) then none get played (?)

brianread108 commented 5 years ago

Also I am able to use a dns name to my emby server vs an IP so we may want to look into that issue

That may be finger trouble on my part - i'll test it again.

brianread108 commented 5 years ago

Also I am able to use a dns name to my emby server vs an IP so we may want to look into that issue

That may be finger trouble on my part - i'll test it again.

Works for me.

rickyphewitt commented 5 years ago

Glad to hear its working! The artist/album are only guaranteed to work when including "from emby/mb". The other implementation uses the common play framework and there is not a defined intent structure, almost the entire intent of the user is passed on and the skill is required to parse it.

If more than one item/object is returned it should play the 1st one. But if you have logs when it doesn't I'd like to see them!

brianread108 commented 5 years ago

ok, here is a log for "plan something from mb"

15:36:57.230 - Emby - INFO - {'media': 'something', 'utterance': 'play something from mb'}
15:37:05.401 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=something
15:37:05.443 - emby_rickyphewitt.emby_croft - INFO - Instant Mix potential match: Something
15:37:05.482 - emby_rickyphewitt.emby_croft - INFO - Instant Mix potential match: Something

and then here is the log for "play something"


15:37:20.968 - Playback Control Skill - INFO - Resolving Player for: something
15:37:26.459 - Playback Control Skill - INFO -    No matches
15:37:29.432 - Emby - INFO - something
15:37:29.433 - root - INFO - phrase: something
15:37:29.434 - emby_rickyphewitt.emby_client - INFO - ?SearchTerm=something
15:37:29.456 - root - INFO - Found: 2 to parse
15:37:29.456 - Emby - INFO - Found match of type: song
15:37:29.457 - Emby - INFO - match levelCPSMatchLevel.TITLE

In the first case I get the song, in the second it tells me "I am not sure how to play "something".

"Something" does appear twice in different albums in my music.

rickyphewitt commented 5 years ago

Ok I see. The 1st intent is being picked up by the skill itself while the second is being picked up with the common play frame work. In both logs 'something' was found. Let me run a few test against the common play framework part of the skill and see if I can reproduce.

rickyphewitt commented 5 years ago

What format is the song 'something'? I was testing artists/songs via the common play path and they all worked. My collection is almost all mp3 and in the past there was an issue where the song was not be transcoded into a format mycroft can play. From what I though that issue should have been fixed.


06:15:06.271 - root - INFO - phrase: on my teeth
06:15:06.271 - emby-skill.emby_client - INFO - ?SearchTerm=on my teeth
06:15:06.285 - root - INFO - Found: 2 to parse
06:15:06.285 - Emby - INFO - Found match of type: song
06:15:06.285 - Emby - INFO - match levelCPSMatchLevel.TITLE
06:15:10.142 - Playback Control Skill - INFO - Playing with: emby-skill
brianread108 commented 5 years ago

"Something" is an mp3 file. It is remote - accessed through a cifs mount.

rickyphewitt commented 5 years ago

I'm having trouble reproducing this with my own collection. Do other songs play using the common framework just not 'something'. Or is it anytime you request a song via common play that it fails?

The thing that really stumps me is that the code is very similar for each and path. In addition the "I am not sure how to play 'something'" is from mycroft. If the emby skill had failed the response would be something like "Unable to find or play 'something'"

I think I'm going to add a debug flag and add extra logging around a few areas. That will hopefully shed more light on the issue.

brianread108 commented 5 years ago

I see this happening whenever the search from emby results in more than one result. Is it the format that is passed through from CPS_match_query_phrase to the CP_Start function via the "song_data" return parameter? I am not very au fait with python structures yet (pascal and php is my recent background) so can't quite work it out.

rickyphewitt commented 5 years ago

I"m consistently able to play results that return 2 or more items. The song_data is a dictionary with a key of the phrase and value a list of song urls to play. I"ve added some quick and dirty logging that will low the first n items that will be played. Update your skill to the latest in the repo and the results will look something like the below logs:

 06:25:10.170 | INFO     | 23825 | Emby | underoath
 06:25:10.170 | INFO     | 23825 | root | phrase: underoath
 06:25:10.170 | INFO     | 23825 | emby-skill.emby_client | ?SearchTerm=underoath
 06:25:10.281 | INFO     | 23825 | root | Found: 2 to parse
 06:25:10.327 | INFO     | 23825 | Emby | Found match of type: artist
 06:25:10.327 | INFO     | 23825 | Emby | match levelCPSMatchLevel.ARTIST
 06:25:10.327 | INFO     | 23825 | Emby | First 3 item urls returned
 06:25:10.327 | INFO     | 23825 | Emby | http://emby:8096/Audio/28299/stream.mp3?api_key=someKeyHERE
 06:25:10.327 | INFO     | 23825 | Emby | http://emby:8096/Audio/28318/stream.mp3?api_key=someKeyHERE
 06:25:10.327 | INFO     | 23825 | Emby | http://emby:8096/Audio/28256/stream.mp3?api_key=someKeyHERE
 06:25:10.328 | INFO     | 23825 | Emby | http://emby:8096/Audio/28308/stream.mp3?api_key=someKeyHERE
 06:25:10.331 | INFO     | 23825 | mycroft.skills.settings:save_settings:109 | Skill settings successfully saved to /opt/mycroft/skills/emby-skill/settings.json
 06:25:14.085 | INFO     | 23825 | Playback Control Skill | Playing with: emby-skill

All those urls should be directly playable via your web browser. You also should be able to access them from the mycroft. Can you test a few of the urls that mycroft won't play and also post the logs. I'd like to see if the urls are in some way incorrect.

Also, apologies for the late reply I came down with a nasty cold.

brianread108 commented 5 years ago

Logs for "play something", then "play beatles"


18:50:19.405 | INFO     |   676 | Emby | something
 18:50:19.406 | INFO     |   676 | root | phrase: something
 18:50:19.407 | INFO     |   676 | emby_rickyphewitt.emby_client | ?SearchTerm=something
 18:50:19.453 | INFO     |   676 | root | Found: 2 to parse
 18:50:19.462 | INFO     |   676 | Emby | Found match of type: song
 18:50:19.462 | INFO     |   676 | Emby | match levelCPSMatchLevel.TITLE
 18:50:19.463 | INFO     |   676 | Emby | First 3 item urls returned
 18:50:19.463 | INFO     |   676 | Emby | http://192.168.100.95:8096/Audio/2741/stream.mp3?api_key=d88d29d93a974acf984ca4cd2f3d917a
 18:50:19.463 | INFO     |   676 | Emby | http://192.168.100.95:8096/Audio/2762/stream.mp3?api_key=d88d29d93a974acf984ca4cd2f3d917a
 18:52:21.003 | INFO     |   676 | Playback Control Skill | Resolving Player for: beatles
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout
 18:52:26.078 | INFO     |   676 | Playback Control Skill |    No matches
Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout
 18:52:29.097 | INFO     |   676 | Emby | beatles
 18:52:29.097 | INFO     |   676 | root | phrase: beatles
 18:52:29.098 | INFO     |   676 | emby_rickyphewitt.emby_client | ?SearchTerm=beatles
 18:52:29.133 | INFO     |   676 | root | Found: 6 to parse
 18:52:29.272 | INFO     |   676 | Emby | Found match of type: artist
 18:52:29.273 | INFO     |   676 | Emby | match levelCPSMatchLevel.ARTIST
 18:52:29.273 | INFO     |   676 | Emby | First 3 item urls returned
 18:52:29.273 | INFO     |   676 | Emby | http://192.168.100.95:8096/Audio/2733/stream.mp3?api_key=d88d29d93a974acf984ca4cd2f3d917a
 18:52:29.274 | INFO     |   676 | Emby | http://192.168.100.95:8096/Audio/2762/stream.mp3?api_key=d88d29d93a974acf984ca4cd2f3d917a
 18:52:29.274 | INFO     |   676 | Emby | http://192.168.100.95:8096/Audio/2765/stream.mp3?api_key=d88d29d93a974acf984ca4cd2f3d917a

``
Nothing played in either case.

If I click on one of the URLs the browser plays the song.`
rickyphewitt commented 5 years ago

The skill finds the items but the common play framework throws a 'Removing event mycroft-playback-control.mycroftai:PlayQueryTimeout'. I'm going to get more information on when this error is thrown. The skill appears to be handling everything as expected but some timeout is being exceeded.

rickyphewitt commented 5 years ago

From the info I could glean it doesn't appear to be related to the skill, but the common play framework. And the url's are being passed as expected to the common play framework. Unfortunately I don't' think changes to the skill will affect this :(

If other issues arise or additional information is found that indicates changes to the emby skill will help this I'll gladly look into this issue future. For now I"m going to close the issue.