Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slugify() function of PyTrakt seems to not rename exactly as Trakt does #165

Open
typhoe opened this issue Nov 18, 2021 · 6 comments · May be fixed by #193
Open

slugify() function of PyTrakt seems to not rename exactly as Trakt does #165

typhoe opened this issue Nov 18, 2021 · 6 comments · May be fixed by #193

Comments

@typhoe
Copy link

typhoe commented Nov 18, 2021

Hi,

this issue is a follow up from an issue I have on PlexTraktSync available here: Taxel/PlexTraktSync#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 into im by PyTrakt module and into i-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

@glensc
Copy link
Contributor

glensc commented Jan 15, 2022

Are you willing to provide a fix?

The current slugify is defined here:

  • PyTrakt/trakt/utils.py

    Lines 10 to 20 in 8a6d4f1

    def slugify(value):
    """Converts to lowercase, removes non-word characters (alphanumerics and
    underscores) and converts spaces to hyphens. Also strips leading and
    trailing whitespace.
    Adapted from django.utils.text.slugify
    """
    nfkd_form = unicodedata.normalize('NFKD', value)
    decoded = nfkd_form.encode('ascii', 'ignore').decode('utf-8')
    value = re.sub(r'[^\w\s-]', ' ', decoded).strip().lower()
    return re.sub(r'[-\s]+', '-', value)

@glensc

This comment has been minimized.

@typhoe
Copy link
Author

typhoe commented Jan 17, 2022

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.

@glensc
Copy link
Contributor

glensc commented Jan 17, 2022

@typhoe are you able to find trakt.tv official docs or description how they slugify? perhaps ask their support?

@typhoe
Copy link
Author

typhoe commented Jan 17, 2022

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 :
Taxel/PlexTraktSync#615 (comment)
and asked me to post here :
Taxel/PlexTraktSync#615 (comment)

I asked on the Trakt ticket support but that could take a while ;-)
https://support.trakt.tv/support/tickets/10789

@typhoe
Copy link
Author

typhoe commented Jan 24, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants