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

Refactor: Get rid of LazyUserList (port functionality to pytrakt) #1826

Closed
glensc opened this issue Feb 23, 2024 · 7 comments · Fixed by #1843
Closed

Refactor: Get rid of LazyUserList (port functionality to pytrakt) #1826

glensc opened this issue Feb 23, 2024 · 7 comments · Fixed by #1843
Labels
enhancement New feature or request

Comments

@glensc
Copy link
Collaborator

glensc commented Feb 23, 2024

Feature description

Use case

There's still some code left that's hacking pytrakt internals:

  • class LazyUserList(UserList):
    @get
    def get_items(self):
    data = yield f"lists/{self.trakt}/items"
    for item in data:
    if "type" not in item:
    continue
    item_type = item["type"]
    item_data = item.pop(item_type)
    self._items.append((item_type + "s", item_data["ids"]["trakt"]))
    yield self._items
    @classmethod
    @get
    def _get(cls, title, id):
    data = yield f"lists/{id}"
    ulist = cls(creator=data["user"]["username"], **data)
    ulist.get_items()
    yield ulist

Plan is to get rid of it, add missing functionality to pytrakt if needed.

@glensc glensc added the enhancement New feature or request label Feb 23, 2024
@glensc
Copy link
Collaborator Author

glensc commented Feb 23, 2024

@simonc56 as I understand the lazy userlist exists for two purposes:

  1. not to create Movie, Episode etc objects
  2. data path is different data = yield f"lists/{self.trakt}/items"

I think the first point was the original purpose (is that reason still valid?), but second difference came from evolution. should pytrakt be changed to use "lists/{trakt}/items" as well? it seems have changed in 7bde749

or add new entity there just for operating "lists", and operations would be only read methods

@simonc56
Copy link
Collaborator

simonc56 commented Feb 23, 2024

LazyUserlist is a kind of hack inspired by LazyEpisode, created to fetch trakt lists faster and avoid hiting rate limit :

About items path, I don't remember anything. Maybe it's changed and needs to be updated.

@simonc56
Copy link
Collaborator

should pytrakt be changed to use "lists/{trakt}/items" as well? it seems have changed in 7bde749

As explained here, fetching a list with its trakt id is "better" because allows to get user lists AND official lists. Maybe you could create a List class (for all kind of lists) instead of the current Userlist (for lists created by trakt users).

@glensc
Copy link
Collaborator Author

glensc commented Feb 24, 2024

List is reserved word (and UserList is also from standard library), but yeah new api seems easier

@glensc
Copy link
Collaborator Author

glensc commented Feb 29, 2024

I'll use PublicList for name:

You must use an integer id, and only public lists will return data.

@glensc
Copy link
Collaborator Author

glensc commented Feb 29, 2024

Started something:

how to find other list types than Movies?

@simonc56
Copy link
Collaborator

simonc56 commented Feb 29, 2024

how to find other list types than Movies?

A trakt list can contain movies, shows, seasons, episodes and people.

But Plex playlist cannot contain such various content.
Only movies and episodes :

And Plex collections can contain movies or shows.

@glensc glensc changed the title Refactor: Get rid of LazyUserList (port functionality to pytratk) Refactor: Get rid of LazyUserList (port functionality to pytrakt) Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants