macr0dev / Audiobooks.bundle

Plex metadata scraper for Audiobooks
600 stars 65 forks source link

Manual searches not working as expected. #17

Closed dethrophes closed 4 years ago

dethrophes commented 6 years ago

You already have a comment int he plugin that the initial manual search doesn't work as expected, however I still find it irritating.

I figured out what I think it s better method to detect the different search types. Namily don't use manual to deicded when to use media.name. instead use media.filename. If media.filename is None then use media.name.

e.g.

`        if media.filename is None:
          # If this is a custom search, use the user-entered name instead of the scanner hint.
          Log('Custom album search for: ' + media.name)
          #media.title = media.name
          media.album = media.name
        else:
          Log('Album search: ' + media.title)
`
macr0dev commented 6 years ago

It's been a few months, but seems like I remember the problem being that the manual search initially tried to use the track title instead of the album, which is what we need. Although I could just be remembering it wrong.

dethrophes commented 6 years ago

Indeed, thought I think it would be better to say that they have 2 different call semantics. The variables passed in are very different in the 2 cases.

With the initial ssearch it is the same as a lib scan and is expected to be handled the same except that options should be displayed. Therefore you are provided with the album, filename etc... and hte name in this case is actually the track title, which makes sense.

If you go go to do a ... manual modified searc then the search is meant to be based solely on the string and year entered... At least that seems to be the intent.

e.g. modified manual search INFO (agentkit:957) - Searching for matches for {'parentID': '796009', 'year': '2015', 'id': '796010', 'name': "L'\xc5\x92il du Temps", 'parentGUID': 'local://796009'} Initial manual search. INFO (agentkit:957) - Searching for matches for {'album': "L'\xef\xbf\xbd\xef\xbf\xbdil du Temps (L'Odyss\xef\xbf\xbd\xef\xbf\xbde du Temps 1)", 'index': '1', 'openSubtitlesHash': '051c61f3ba1b2c66', 'name': "L'\xc5\x92il du Temps (L'Odyss\xc3\xa9e du Temps 1)", 'artist': 'Arthur C. Clarke', 'parentID': '796009', 'filename': '%2Fvolume1%2FOther%2FaBooks%2Eaudible%2Efr%2FArthur%20C%2E%20Clarke%2FLil%20du%20Temps%20(LOdysse%20du%20Temps%201)%2F001%20-%20Lil%20du%20Temps%20(LOdysse%20du%20Temps%201)%2Em4b', 'parentGUID': 'local://796009', 'plexHash': 'a2e58990dfef4a8a74120d6f9f0e68d8629da7f8', 'duration': '21354975', 'title': None, 'id': '796010'}

As such from what I can infer it is more correct to decide when to use name based on a different trigger than manual.

jmeosbn commented 6 years ago

I have something similar, but based on prioritising album if available:

if media.album is None:
    if not manual:
        self.Log('Album Title is NULL on an automatic search.  Returning')
        return
    media.album = media.name

media.album is previously set to None if found to be [Unknown Album].

Before that I'm currently messing with trying to find something better than the name to fill in an empty album field but haven't done much with it just yet. (Plex seems to do something similar, but splits the path strictly as .../<artist> - <album>/<name>.ext)

# get possible title from parent folder name
if media.album is None and media.filename:
    dirname  = os.path.dirname(urllib.url2pathname(media.filename))
    media.album = os.path.basename(dirname)
    ...

This allows a completely untagged file to be matched so long as it's in a properly named folder - and of course, the above is a very simple case which needs to be made more robust.

macr0dev commented 4 years ago

Looks like this is currently implemented but just never closed.

Closing.