jurialmunkey / plugin.video.themoviedb.helper

GNU General Public License v3.0
203 stars 96 forks source link

[Feature / Discussion] Add Trakt list to library #153

Closed jurialmunkey closed 4 years ago

jurialmunkey commented 4 years ago

@drinfernoo (and any others that want to test) - When you get a chance, can you test out this new feature which allows you to add a complete Trakt list to the library in one go and let me know if there's any issues?

You should now be able to use "Add to Kodi Library" context menu item on any list in Trakt > Trending / Popular / Liked / Your Lists and every item in the list will be added to the library.

This approach will be useful for users that want to add a large number of items to the library in one go whilst also avoiding the circular logic of other addons that misuse Trakt's collection feature for this purpose.

Now users can create a custom list of "subscriptions" on Trakt which they can then add to Kodi in one go from the "Your Lists" section. Currently you would still need to re-add the list manually if you add new shows to it (only new shows, because shows already added auto update) - but in the future I'll also look at adding a list monitoring feature that will update from a list on startup.

Let me know if you find any issues. It seems to be working well on my end (and is surprisingly fast but I've only tested on my laptop which has an SSD, so might be slower on devices with HDDs).

jurialmunkey commented 4 years ago

Honeyview_screenshot722

Honeyview_screenshot723

drinfernoo commented 4 years ago

This seems to work pretty well, and I really appreciate the dialog that it shows!

It seems to only do this when I add one of my "Liked Lists", but it hangs on a busy dialog until all the items in the list have been added. The other sections don't seem to do this.

drinfernoo commented 4 years ago

Do you also intend on adding this functionality for the Collection and/or Watchlist?

angelitto2005 commented 4 years ago

I tested too, on a list from ”Liked Lists” and everything was ok, except from dialog with ”unable to create paths”, but after i disable in settings ”ignore folder creation cheks”, i got no warnings and all the movies was added to Library succesfully. This option is very cool. I wonder if you can implement an option to add a movie from Library to one of my Trakt lists. Will be usefull. I think Exodus have something like that. (if you wanna take a look). Just a suggestion for future updates.

drinfernoo commented 4 years ago

@Demonseeed It did do that for me. I added both a liked list of Studio Ghibli films, and also my personal lists of anime films, and it didn't duplicate them.

angelitto2005 commented 4 years ago

It will not duplicate, but, if you add that movie from another addon, then you will have 2 entries in library.

drinfernoo commented 4 years ago

@angelitto2005 Ah, good point. Another thing I didn't test was if it would duplicate items which are in the library from a local file.

jurialmunkey commented 4 years ago

@drinfernoo

This seems to work pretty well, and I really appreciate the dialog that it shows!

Yeah it is pretty essential, especially since the adding runs in the background. When I was testing I realised it was needed after I accidentally added a list with 1000s of items and had to force quit Kodi.

It seems to only do this when I add one of my "Liked Lists", but it hangs on a busy dialog until all the items in the list have been added. The other sections don't seem to do this.

I've now switched to using the extended progress dialog so the busy dialog won't steal focus and it will now run truly in the background just like a library update.

Do you also intend on adding this functionality for the Collection and/or Watchlist?

Watchlist YES. Collection NO.

People need to stop misusing the collection feature this way. The whole point is to keep "track" of what media you've physically collected and own. Apps should sync to the collection, NOT from it - otherwise you end up in a loop (local item gets added to collection which then gets added to local items).

Users should create a separate list of "Subscriptions" for items that they have access to from streaming sources. The Trakt addon should then be told not to sync TMDbHelper's library folders. That way you keep your collection of items that you own separate from items that you have access to on streaming services -- You can't say you've "collected" items on streaming services. That would be like saying you've collected all the books in your local library...

jurialmunkey commented 4 years ago

@angelitto2005

I tested too, on a list from ”Liked Lists” and everything was ok, except from dialog with ”unable to create paths”, but after i disable in settings ”ignore folder creation cheks”, i got no warnings and all the movies was added to Library succesfully. This option is very cool.

Excellent - thanks for testing. Yeah it's weird that on some systems Kodi misreports that the folder hasn't been created. It's annoying that the folder creation error checking needs to be disabled - but at least so far it seems all the folders get created properly.

I wonder if you can implement an option to add a movie from Library to one of my Trakt lists.

Yeah, I was thinking that would be a useful option. I find often when just browsing TMDbHelper I want to add an item to one of my lists that isn't my watchlist. I also want to add an option to remove an item from a list.

jurialmunkey commented 4 years ago

@Demonseeed - Yeah currently TMDbHelper doesn't check the library for existing files -- it just rewrites everything that you add but because the naming is standardised it can't create duplicates. I will add an option soon to double check library and skip items that are in there.

jurialmunkey commented 4 years ago

@Demonseeed @drinfernoo @angelitto2005 - Can you all test latest version. The plugin should now skip items that are already in your library.

skyfsza commented 4 years ago

Great feature, thanks for adding!

Any chance you can enable "TV Shows --> Your In-progress" to be added to library? Would allow users to add all shows they are currently watching on Trakt to the library (without manually creating a new list).

jurialmunkey commented 4 years ago

Great feature, thanks for adding!

Any chance you can enable "TV Shows --> Your In-progress" to be added to library? Would allow users to add all shows they are currently watching on Trakt to the library (without manually creating a new list).

This doesn't really make sense to me - particularly since in-progress only displays shows that still have unwatched episodes (you could have watched all currently aired episodes but there's still upcoming episodes - those shows wouldn't get added because they aren't in progress).

There's an option in settings to auto update tvshows for new episodes on startup. All you have to do is enable that and add one episode of a show, then tmdbhelper will update the episodes automatically.

angelitto2005 commented 4 years ago

Works flawlessly. I tested a ”Trakt Test List” with 6 movies. 3 from local library, 2 added by another addon, and the last one (The Matrix) I didn't have it in the library. When i added the list, it skipped all the movies, except The Matrix. Good job!

jurialmunkey commented 4 years ago

Works flawlessly. I tested a ”Trakt Test List” with 6 movies. 3 from local library, 2 added by another addon, and the last one (The Matrix) I didn't have it in the library. When i added the list, it skipped all the movies, except The Matrix. Good job!

Excellent! Yeah I'm a little surprised at how well the library check is working -- I'm really expecting something to break it but so far so good!

skyfsza commented 4 years ago

Great feature, thanks for adding! Any chance you can enable "TV Shows --> Your In-progress" to be added to library? Would allow users to add all shows they are currently watching on Trakt to the library (without manually creating a new list).

This doesn't really make sense to me - particularly since in-progress only displays shows that still have unwatched episodes (you could have watched all currently aired episodes but there's still upcoming episodes - those shows wouldn't get added because they aren't in progress).

There's an option in settings to auto update tvshows for new episodes on startup. All you have to do is enable that and add one episode of a show, then tmdbhelper will update the episodes automatically.

It's definitely not a perfect solution and i'm shooting from the hip, but my thought process was it could provide a way for tmdbhelper to sync with trakt's inherent show tracking and avoid having to manually add shows to a separate list.

Trakt automatically begins "monitoring" shows after you watch a single episode so that it can maintain your Calender and Next up. Tmdbhelper in-progress is a single list of all the shows trakt is "tracking/monitoring" that have unwatched episodes.

If you add the in-progress list to the library, the initial sync would be all your shows with unwatched episodes (80% of shows in my case). If you are able to add list monitoring to tmdbh, for shows that trakt is tracking that don't have unwatched episodes, as soon as a new episode airs the show would appear in "in-progress" and tmdbhelper would automatically add/sync it to the library.

It would also mean that as trakt begins tracking a new show (after you watched first episode) tmdbhelper would auto add to library without requiring you to manually add each new show to your "subscription list".

juanma-cvega commented 4 years ago

A question about this new feature. Is it possible for the addon to add the elements to playlists named after the Trakt list they are imported from? I was thinking that could be a way to speed up widgets as you could create them from local library instead of from the addon. Is there any limit to how many items are pulled from the list being synced? Within widgets there is the limit to the amount of items Trakt sends back but as far as I know from the local library this limitation could be avoided. And another question. Are elements removed from a list also being removed from the library?

jurialmunkey commented 4 years ago

A question about this new feature. Is it possible for the addon to add the elements to playlists named after the Trakt list they are imported from? I was thinking that could be a way to speed up widgets as you could create them from local library instead of from the addon.

Not currently but that is a really interesting idea. It would be relatively easy to do - just create a smart playlist with a rule matching each filename and match set to any; then just save and drop in the playlists folder. I'm not sure if smart playlists cope well with a large number of rules like that (list of 100 items would be a playlist with 100 matching rules).

Is there any limit to how many items are pulled from the list being synced? Within widgets there is the limit to the amount of items Trakt sends back but as far as I know from the local library this limitation could be avoided.

No limit. The entire trakt list is pulled in one call and then every item is added. If there's 1000 items in the list then 1000 items will be added to the library (that's why there's a warning about how many items are in the list).

The reason lists are paginated into smaller pages of 20 items when accessing through TMDbHelper is because each item in the list needs another call to lookup the details (e.g. artwork, plot etc.) and looking up the details of all the items takes time (imagine if accessing the library required the an entire library update from scratch every time). Adding to the library isn't time critical, so we can let the scraper do the detailed lookup in the background and take its time.

And another question. Are elements removed from a list also being removed from the library?

No. Once the item is added to the library it exists as a physical strm file (a text file with a shortcut link to the plugin path). You need to delete the actual file off your hard-drive to remove it from your library.

juanma-cvega commented 4 years ago

No. Once the item is added to the library it exists as a physical strm file (a text file with a shortcut link to the plugin path). You need to delete the actual file off your hard-drive to remove it from your library.

Would it be too complex to implement? I guess there is going to be a conflict between an element being removed from one list (the one that actually add it to the library in the first place) while another one still has it (the one that didn't add it to the library to avoid duplication). But without this feature, trending lists and the like would lose their purpose as they would create an ever growing playlist.

jurialmunkey commented 4 years ago

It's definitely not a perfect solution and i'm shooting from the hip, but my thought process was it could provide a way for tmdbhelper to sync with trakt's inherent show tracking and avoid having to manually add shows to a separate list.

Trakt automatically begins "monitoring" shows after you watch a single episode so that it can maintain your Calender and Next up. Tmdbhelper in-progress is a single list of all the shows trakt is "tracking/monitoring" that have unwatched episodes.

@skyfsza - but then you end up with the same circular logic as you do with adding a collection. You're syncing what you've watched locally to Trakt and then what you've watched gets synced back to your local library.

The only way that works is if you literally have zero actual physical files. As soon as you add physical files you end up with a mess of a library.

Image this scenario: I download the first few episodes of a show to see if I like it. After I watch the first episode, suddenly I have six seasons of strm episodes added to my library. If I like the show and download more episodes, then I need to go delete all the TMDbHelper strm files and cleanup my library so that I can add the local files. If I didn't like the show, I also need to clean all the shows out of my library. Either way, my library ends up a mess.

Imagine this scenario: I use my PVR to setup a timer to record a show that airs weekly. I watch an episode. My watched history gets synced to Trakt. TMDBHelper then adds that show to my library. TMDbHelper adds the next episode to my library before I've finished recording it. Now I've got two copies in my library (a TMDbHelper strm and my PVR recording).

Imagine this scenario: A friend stays over and watches an episode of Judge Judy. Suddenly I have a million episodes of Judge Judy added to my library...

I can think of so many reasons why it would be a really bad idea.

jurialmunkey commented 4 years ago

Would it be too complex to implement? I guess there is going to be a conflict between an element being removed from one list (the one that actually add it to the library in the first place) while another one still has it (the one that didn't add it to the library to avoid duplication). But without this feature, trending lists and the like would lose their purpose as they would create an ever growing playlist.

@juanma-cvega - I would be very hesitant to give an external list the power to delete items in the library. Anyway, it wouldn't create a growing playlist because the playlist would be recreated every time the list updates on startup - so the playlist would reflect the items in the list. Plus you don't need to remove any thing from the library that way - you just add/remove items from the playlist.

drinfernoo commented 4 years ago

@jurialmunkey

Not currently but that is a really interesting idea. It would be relatively easy to do - just create a smart playlist with a rule matching each filename and match set to any; then just save and drop in the playlists folder. I'm not sure if smart playlists cope well with a large number of rules like that (list of 100 items would be a playlist with 100 matching rules).

I implemented this is in a different add-on, and simply wrote a library tag (containing the Trakt slug of the source list) to the NFO for the item as it was generated. Then I also generated the matching smart playlist that contained items with that tag.

I could submit that code here of you'd like, as it seems like it would "plug and play" 😉

jurialmunkey commented 4 years ago

@jurialmunkey

Not currently but that is a really interesting idea. It would be relatively easy to do - just create a smart playlist with a rule matching each filename and match set to any; then just save and drop in the playlists folder. I'm not sure if smart playlists cope well with a large number of rules like that (list of 100 items would be a playlist with 100 matching rules).

I implemented this is in a different add-on, and simply wrote a library tag (containing the Trakt slug of the source list) to the NFO for the item as it was generated. Then I also generated the matching smart playlist that contained items with that tag.

I could submit that code here of you'd like, as it seems like it would "plug and play" 😉

@drinfernoo - Ah yeah that's a way better idea - I was thinking about something to do with tags would be a way to do it but couldn't think how you would add them (I completely blanked on being able to add them to the nfo file). Yeah you would just need to join the user slug and trakt list slug as the tag, then generate the tag based on it.

I guess the downside is the scenario @juanma-cvega mentioned - when you update from a trending list, you would also need to update all the tags in the library. Whereas if you match to filenames, then you can just add and remove the separate filenames from the playlist without touching the existing library entries.

juanma-cvega commented 4 years ago

Anyway, it wouldn't create a growing playlist because the playlist would be recreated every time the list updates on startup

Ok, I didn't know that. Do you have any plans to add a cron job so there is no need to restart Kodi? I'm thinking of systems that stop it for a long time. For instance, I use it on a shield and it doesn't close Kodi when I switch it off. And a way to refresh it manually from the skin would be nice as well in case you add an item from your phone to a list and then you want to see it on Kodi.

drinfernoo commented 4 years ago

You could, if the item already exists in the library, open it's NFO file and add the new tag.

dm2912 commented 4 years ago

Do you also intend on adding this functionality for the Collection and/or Watchlist?

+1 for Watchlist, that would be helpful.

Collections, meh, im doing my best to get my colleciton back to stuff i actually have collected :D :D

Oh.. library location works fine to SMB now.

jurialmunkey commented 4 years ago

@juanma-cvega @drinfernoo - I've now added the smart playlist creation function. When you add a list, TMDbHelper will auto generate a smart playlist in your playlists folder containing the items. If the list has a mix of tvshows and movies, then a smart playlist will be created for each type (one for movies and one for tv).

I'm just matching by Title, but it seems to work fine.

chrisd-2k commented 4 years ago

I must be doing something wrong. I created some lists on Trakt, then opened tmdb helper in Kodi, browsed to the list and selected add to Kodi library. It scanned through the list so everything looked Ok but when selecting TV Shows from Kodi home screen nothing appears to have been added.

There doesn't appear to be any additional sources added within media locations (other than my nas) within Kodi media library.

drinfernoo commented 4 years ago

@chrisd-2k You need to add the sources and set them up with a library scraper as well.

chrisd-2k commented 4 years ago

I can't browse to the location where tmdb keeps them though

chrisd-2k commented 4 years ago

Thanks for the help though I should add this is an android installation (don't know if that's different)

drinfernoo commented 4 years ago

You need to "Show hidden files and directories".

chrisd-2k commented 4 years ago

You need to "Show hidden files and directories".

Didn't even see that. Thanks for the help all working

djnield commented 4 years ago

@juanma-cvega @drinfernoo - I've now added the smart playlist creation function. When you add a list, TMDbHelper will auto generate a smart playlist in your playlists folder containing the items. If the list has a mix of tvshows and movies, then a smart playlist will be created for each type (one for movies and one for tv).

I'm just matching by Title, but it seems to work fine.

Am looking for this option. Which version did you implement it?

jurialmunkey commented 4 years ago

@djnield - v2.4.9

djnield commented 4 years ago

@djnield - v2.4.9

I'm at 2.4.13 I should be able to see the generated playlist in the playlist folder?

I'm not seeing a thing there. My hope was to point a homescreen widget to it. But nothing is showing 🤔

drinfernoo commented 4 years ago

I am getting the generated playlists, but the way that they are matching by title messes up things with the same title.

For example, I have two liked Trakt lists, "Disney Animated Classics", and "Disney Live-Action Movies", each with a different version of "Aladdin" 😅

dm2912 commented 4 years ago

Having done some playing last night. Some thoughts on watchlist versus collection library maintenance.

I have realised why people use collection as their library stores.

A show is on my watchlist. As soon as I watch 1 episode of that show trakt remove it from my watchlist. So using a watchlist for library integration doesn't work because as soon as you watch even 1 episode thats it zapped, its no longer in watchlist, so your library will no longer update.

Trakts logic is that once you have watched one episode then you start using the "progress" feature to keep up to date with episodes and watch them.

but from a kodi library maintenance pov that is useless.

So despite it being contrary to the "collection is things you physically own", I can see why collection is preferred over watchlist for Kodi library purposes.

Trakt removing things from watchlist as soon a single episode is watched makes it useless for an ongoing thing.

drinfernoo commented 4 years ago

And without a way to reliably add things to personal lists inside Kodi, it becomes very inconvenient to have to maintain a separate, long-running list of shows we're watching... especially when Trakt provides this as one of it's key selling points, in the form of its "progress" sections.

jurialmunkey commented 4 years ago

@dm2912 - I don't think watchlist is effective either - it's just a quick way to add new shows. A personal list of shows that you are "subscribing" to is the method I'm suggesting.

I think it is really a bad idea to automatically add everything that you watch to the library.

For instance, imagine if a friend stays over and watches one episode of a soap like Days of our Lives. Suddenly you would have 13000+ episodes added to your library. That's a lot of TMDb/TVDb bandwidth wasted for something that you maybe don't even watch and it will be a pain to now clean your library. Thinking that this sort of excessive look-up is okay is completely disrespectful to the online services that provide all this data for free.

If you want on-the-fly access to what you've recently watched, just use a TMDbHelper widget for that purpose - that's why they exist. Plus, once you've setup your main list of subscriptions, all it takes to add a new show to the library is a single context menu click. Once you add one episode, TMDbHelper handles the rest.

jurialmunkey commented 4 years ago

And without a way to reliably add things to personal lists inside Kodi, it becomes very inconvenient to have to maintain a separate, long-running list of shows we're watching... especially when Trakt provides this as one of it's key selling points, in the form of its "progress" sections.

@drinfernoo - That's why there's an in-progress TMDbHelper widget - for on-the-fly access to your in-progress shows. -- Accessing the widget is going to be way faster than waiting for TMDbHelper to update your library.

Plus, once you have your main set of shows setup, it's only one context menu click to add a new item to your library - you only have to add one episode and then TMDbHelper handles the rest.

I already mentioned in this thread that I'm planning for a context menu item to add/remove from a personal trakt list. I've almost got this one ready to go - so it will be in before the list monitoring feature is even added.

jurialmunkey commented 4 years ago

I am getting the generated playlists, but the way that they are matching by title messes up things with the same title.

For example, I have two liked Trakt lists, "Disney Animated Classics", and "Disney Live-Action Movies", each with a different version of "Aladdin" 😅

For some reason I didn't even think about remakes. I guess a year field will help that. EDIT: Nope that doesn't work because needs to be match ANY... maybe I can check against something else. EDIT2: Ah - matching by filename works for movies. Tvshows will need to stay match by title though (especially since path can possibly be split between two locations).

drinfernoo commented 4 years ago

@jurialmunkey My original solution worked very well for me: write a tag into the NFO file, that matches the Trakt slug, and then use that tag as the rule in a playlist.

jurialmunkey commented 4 years ago

@jurialmunkey My original solution worked very well for me: write a tag into the NFO file, that matches the Trakt slug, and then use that tag as the rule in a playlist.

@drinfernoo - The problem is that items already in the library are skipped, so you can't write a tag for them. It would be a bad idea to write an nfo file to a part of the user's library that isn't the source specified for TMDbHelper.

e.g. I keep my local file sources in a separate location from the TMDbHelper ones. I've got a handful of obscure items that don't scan properly and need nfo files. I would be so annoyed if the TMDbHelper overwrote my custom nfo files and I needed to remake them.

drinfernoo commented 4 years ago

@jurialmunkey Well, you wouldn't. Only tag the ones that come from the sync, and leave the rest, in my opinion. Matching by filename likely wouldn't work in the situation you describe either, unless you're naming your actual video files the same as your STRMs.

jurialmunkey commented 4 years ago

@jurialmunkey Well, you wouldn't. Only tag the ones that come from the sync, and leave the rest, in my opinion. Matching by filename likely wouldn't work in the situation you describe either, unless you're naming your actual video files the same as your STRMs.

It does work though - I've already tested it. I have to get the Kodi DB anyway to check if the item is in the library, so I just ask it to return "file" instead of "dbid". https://github.com/jurialmunkey/plugin.video.themoviedb.helper/blob/master/resources/lib/context.py#L198

Then I add it to the list of item rules: https://github.com/jurialmunkey/plugin.video.themoviedb.helper/blob/master/resources/lib/context.py#L200

Then I build the smart playlist: https://github.com/jurialmunkey/plugin.video.themoviedb.helper/blob/master/resources/lib/context.py#L223-L236

Here's a section of a playlist created by adding a list of Arnold Schwarzenegger movies. I already had Terminator 2 in my library as a local mp4 file and I already had Last Action Hero as a strm. All items were added to the playlist correctly:

<rule field="filename" operator="is"><value>Kindergarten Cop (1990).strm</value></rule>
<rule field="filename" operator="is"><value>Terminator 2.mp4</value></rule>
<rule field="filename" operator="is"><value>Last Action Hero (1993).strm</value></rule>
jurialmunkey commented 4 years ago

@drinfernoo - The "Add to Trakt List" context menu item is now live. Should work for all TMDbHelper items, and hopefully most other items.

It doesn't currently work for library episodes - only the base tvshow - but that's just because I need to figure out what the best way is to retrieve base tvshow IDs from an episode -- currently only adding a full tvshow to the list rather than individual episodes because I figure people probably want it to act the same way as watchlist.

angelitto2005 commented 4 years ago

I can confirm, it works. I added from my Kodi Library and from TMDB. Both, Movies and Shows. Single episod doesnt work, but i dont get the point for adding a single episod in a List... From other addons, doesnt work either, but this doesnt matter too much. You did a great job implementing this option. I wonder if you can go further and add an option to remove an item from Trakt lists. Will be nice, too. And another ideea for future updates. Maybe a submenu with ”Trakt Add/Remove”is better for ”Add/Remove from Trakt Watchlist, History, Collection” options.

jurialmunkey commented 4 years ago

You did a great job implementing this option. I wonder if you can go further and add an option to remove an item from Trakt lists. Will be nice, too.

I've got a remove option coming soon. Just wanted to make sure that these new features are working properly before I add more options.

And another ideea for future updates. Maybe a submenu with ”Trakt Add/Remove”is better for ”Add/Remove from Trakt Watchlist, History, Collection” options.

Yeah, I think maybe a submenu is warranted now since there's quite a few options.

jurialmunkey commented 4 years ago

Now also added a List monitor option in settings that allows you to choose a Trakt list to watch for updates. Can now also set a time interval to do updates.