PyTrakt
PyTrakt copied to clipboard
slugify() function of PyTrakt seems to not rename exactly as Trakt does
Hi,
this issue is a follow up from an issue I have on PlexTraktSync available here: https://github.com/Taxel/PlexTraktSync/issues/615
Two examples of shows that are not slugified correctly: https://trakt.tv/shows/re-zero-starting-life-in-another-world https://trakt.tv/shows/so-i-m-a-spider-so-what
I will quote the collaborator from PlexTraktSync:
On RE-Zero
:
That's a very specific issue because of this show's name using - symbol :
Re:ZERO -Starting Life in Another World-
The trailing dash has been removed in Trakt slug version :re-zero-starting-life-in-another-world
whereas the pytrakt module does not remove it with its own slugify() function :re-zero-starting-life-in-another-world-
so it doesn't match and trakt API returns 404 error.
On So-I'm-a-spider
:
it's the
i'm
slugified intoim
by PyTrakt module and intoi-m
in trakt database. It's clearly a problem in slugify() function of PyTrakt module. It does not slugify exactly as official trakt.tv does.
Thank you
Are you willing to provide a fix?
The current slugify is defined here:
- https://github.com/moogar0880/PyTrakt/blob/8a6d4f168a858447014fb4c2c0efceb47b30ebb7/trakt/utils.py#L10-L20
ps: edit your issue and use backticks for title, so it's better visible when rendered:
`some text inside backticks`
Hi, I added the backticks for readability but I'm sorry but I won't be able to provide any fix. I only used a workaround to bypass the issue on PlexTraktSync.
@typhoe are you able to find trakt.tv official docs or description how they slugify? perhaps ask their support?
No sorry.
I only posted my issue here because one of the dev from PlexTraktSync told me the issue seemed to be from the slugify() function : https://github.com/Taxel/PlexTraktSync/issues/615#issuecomment-972825342 and asked me to post here : https://github.com/Taxel/PlexTraktSync/issues/615#issuecomment-972928210
I asked on the Trakt ticket support but that could take a while ;-) https://support.trakt.tv/support/tickets/10789
Hi,
Justin of Trakt support answered me, I'll copy/paste their answer below:
The rules would be defined in https://github.com/norman/friendly_id/ but in general I'd recommend using IDs to match and not relying on a slug. If you know the Trakt ID, that can be used in the URL or you use some of the lookup functionality we have like this:
https://trakt.docs.apiary.io/#reference/search/id-lookup/get-id-lookup-results https://trakt.docs.apiary.io/#introduction/website-media-links
I'd highly recommend using IDs since Trakt could have different titles (and thus different slugs) compared to TMDB or TVDB.