Taxel / PlexTraktSync

A python script that syncs the movies, shows and ratings between trakt and Plex (without needing a PlexPass or Trakt VIP subscription)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

glensc opened this issue · comments

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.

@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

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.

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).

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

I'll use PublicList for name:

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

Started something:

how to find other list types than Movies?

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.