[WIP] Delete After Watching
#1
[Update 2-22-2021] Not Dead Yet
I uploaded the source to github, and updated it to work with Kodi 19 (py3).

[Update 8-10-2020] Abandoned
I gave up on this several years ago.  The source is posted, so have at it.

What is it?

Delete After Watching (DAW) is a program addon to make your Kodi install behave more like a DVR. Once you have watched a video, it will prompt you to ask if you would like to delete and remove from library.

Features
 
  • Configurable to prompt for delete only for certain types of video (Movies, TV, or Non-Library video)
  • Configurable to prompt for delete only after the first time you've watched a particular video
  • Default response is "No", meaning "do not delete". 2 Minute idle timer will also choose this option

Known Issues
  • This script does NOT honor the "Allow file renaming and deletion" kodi setting. It should, and will in the next version.
  • This only deletes the file being played. It doesn't delete any fanart, subtitiles, .nfo or the parent directory. If I can find a way to identify all of that, I'll add that ability.
  • github site not yet up. Source is obviously in the .zip file if you're curious.

Warning
DAW will delete your files when you ask it to. On most platforms, they are not recoverable - there is no "recycle bin" or holding area. Use the configuration settings to only enable this option for media you wish to delete. To protect media you don't want to delete, make sure to "unselect" it in the configuration. All media is "unselected" by default, the script will never delete anything unless you have both configured it to do so, and manually selected "yes" when prompted to delete.

How does it work

DAW registers for notification when media is started and stopped. When playback is stopped, DAW checks to see if the just played media has been "selected" for prompting. If so, it will ask the user if they want to delete the just finished media. If the user chooses "yes", DAW will delete the media files and remove it from the library.

Download

script.service.daw:
https://github.com/teaguecl/delete_after_watching

License

GNU GENERAL PUBLIC LICENSE. Version 3, June 2007

Acknowledgments
Roman_V_M for PyXBMCt
Pynto R for the After Watch addon


Background
My original feature request from 2010: http://forum.kodi.tv/showthread.php?tid=83263
Feature request from 2011: http://forum.kodi.tv/showthread.php?tid=98470
Feature request from 2013: http://forum.kodi.tv/showthread.php?tid=159221
Feature request from 2014: http://forum.kodi.tv/showthread.php?tid=185159
Similar feature baked into Simplicity skin: http://forum.kodi.tv/showthread.php?tid=98567
Team member saying that this feature belongs in the Core: http://forum.kodi.tv/showthread.php?tid=...pid1253897
Reply
#2
I downloaded this and tried it out. The first time I watched an episode and finished nothing happened. I figured out that I didn't watch it to the end, rather I stopped it with about 2 minutes left. I regularly pad 1 minute on each end of my recordings, so I basically never make it to the end of the recording. Once I fast forwarded to the end it worked as expected.

Is there some way to intercept playback stopping even if it's not at the end? I'd be fine with it as an option. Or if you're already waiting until x minutes before the end to trigger things, maybe that could be user set?
Reply
#3
(2016-05-16, 06:24)pkscout Wrote: I downloaded this and tried it out. The first time I watched an episode and finished nothing happened. I figured out that I didn't watch it to the end, rather I stopped it with about 2 minutes left. I regularly pad 1 minute on each end of my recordings, so I basically never make it to the end of the recording. Once I fast forwarded to the end it worked as expected.

Is there some way to intercept playback stopping even if it's not at the end? I'd be fine with it as an option. Or if you're already waiting until x minutes before the end to trigger things, maybe that could be user set?

Thanks for trying it out, much appreciated. The current mechanism for detecting whether a video has been completed or not is by using Kodi's internal "watched" status. This gets triggered when Kodi's 'playcount' for a video goes from 0 to 1. The playcount itself only gets incremented when Kodi determines you've watched to the end - I think it's based on a percentage of the overall video length, and I don't believe it's configurable. In a perfect world, Kodi would make that configurable and then the addon could rely on Kodi's determination.

I could modify the addon to behave differently. I could calculate "watched" status myself. That way I could expose this in the settings, and you could for example set the criteria to 80% instead of Kodi's 90%. This is a little tricky, since Kodi doesn't really expose this information in a convenient way, but I'm sure something can be done.

I will add it to my list of things to investigate. If it can be done cleanly, I'd be happy to add it.
Reply
#4
(2016-05-16, 21:53)teaguecl Wrote: Thanks for trying it out, much appreciated. The current mechanism for detecting whether a video has been completed or not is by using Kodi's internal "watched" status. This gets triggered when Kodi's 'playcount' for a video goes from 0 to 1. The playcount itself only gets incremented when Kodi determines you've watched to the end - I think it's based on a percentage of the overall video length, and I don't believe it's configurable. In a perfect world, Kodi would make that configurable and then the addon could rely on Kodi's determination.

I could modify the addon to behave differently. I could calculate "watched" status myself. That way I could expose this in the settings, and you could for example set the criteria to 80% instead of Kodi's 90%. This is a little tricky, since Kodi doesn't really expose this information in a convenient way, but I'm sure something can be done.

I will add it to my list of things to investigate. If it can be done cleanly, I'd be happy to add it.

It's configurable in advancedsettings.xml

PHP Code:
<advancedsettings>
    <
video>
         <
playcountminimumpercent>80</playcountminimumpercent>
    </
video>
</
advancedsettings

Not sure if this will help you too much though.
Learning Linux the hard way !!
Reply
#5
(2016-05-16, 22:08)black_eagle Wrote:
(2016-05-16, 21:53)teaguecl Wrote: Thanks for trying it out, much appreciated. The current mechanism for detecting whether a video has been completed or not is by using Kodi's internal "watched" status. This gets triggered when Kodi's 'playcount' for a video goes from 0 to 1. The playcount itself only gets incremented when Kodi determines you've watched to the end - I think it's based on a percentage of the overall video length, and I don't believe it's configurable. In a perfect world, Kodi would make that configurable and then the addon could rely on Kodi's determination.

I could modify the addon to behave differently. I could calculate "watched" status myself. That way I could expose this in the settings, and you could for example set the criteria to 80% instead of Kodi's 90%. This is a little tricky, since Kodi doesn't really expose this information in a convenient way, but I'm sure something can be done.

I will add it to my list of things to investigate. If it can be done cleanly, I'd be happy to add it.

It's configurable in advancedsettings.xml

PHP Code:
<advancedsettings>
    <
video>
         <
playcountminimumpercent>80</playcountminimumpercent>
    </
video>
</
advancedsettings

Not sure if this will help you too much though.
Thanks for that - I didn't know that was configurable! I think this does address the issue. If pkscout sets this to 70% (or 75% or whatever works best for him) then my addon will honor Kodi's determination on "watched" status.
I should add this to my README file, as I think it will be a commonly requested feature.
Reply
#6
I can change the play count minimum, but it could cause me problems. I had it set to 101% so that Kodi didn't mark things as watched. Why? Because I have it set to hide things that are watched. Otherwise I couldn't find them to delete them. I'll try setting it to 94% (or maybe 90%) and let this addon delete shows for me. The only time this will fall apart is if I have to stop watching something with just a few minutes left. It'll disappear from my list (because it's marked as watched), and I'll have to hunt it down. Maybe that's an oddity of how I use Kodi (I have blu-ray ripped shows like Game of Thrones that I don't want to clutter the TV Show interface once I've watched them, but I don't want them deleted). I'll own that. '-)
Reply
#7
(2016-05-16, 21:53)teaguecl Wrote: Thanks for trying it out, much appreciated. The current mechanism for detecting whether a video has been completed or not is by using Kodi's internal "watched" status. This gets triggered when Kodi's 'playcount' for a video goes from 0 to 1.
I wanted to wrap back around to this. I have set the play counter to advance if I watch more than 94% of a video. Now if I get to that point and hit stop I don't get the delete dialog. I just end up back at the screen with the list of TV episodes, and the one I was watching is marked as watched. So I know the 'mark as watched' logic is working correctly. The only way I can get the delete dialog box to appear is if I skip forward to the very end of the video.

I'll try to get some debug logs later today or tomorrow.
Reply
#8
pkscout, I think I've captured the same behavior locally. Kodi is weird.

If you watch a show all the way to the end, you will get a Player.OnStop event - and in that event is a field called 'end' that indicates you've watched the whole thing. Also, the playcount will increase.

If you watch 99% of a show, then hit the "stop" button something else happens. You get a Player.OnStop event, but the 'end' field is set to FALSE. Then, about one second later, Kodi comes around and updates the video library (VideoLibrary.OnUpdate event) to mark the show as watched, and increment the playcount.

So from the Player objects point of view the video is not watched - but one second later the library is updated to show that it is. I can probably add some code to deal with this unexpected behavior, but I honestly think it's a bug in Kodi: I believe the Player.OnStop should have 'end' set to TRUE in this situation.
Reply
#9
@teaguecl I suggest you check the trakt addon.
It deals with the same kind of detection you need to update trakt and works fine...

I haven't tried your addon, yet, but I'm interested. I'd use it only for some specific TV shows, though, so would be great to have some kind of inclusion/exclusion mechanism.
Reply
#10
Are you aware of the already existing after watch add-on?
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#11
(2016-05-21, 15:00)DarrenHill Wrote: Are you aware of the already existing after watch add-on?

Yes, Afterwatch is a nice addon. I felt it was a little too complicated to configure and use since it does so much - IMDB ranking, etc. I intended Delete After Watching to be a subset of those features but simpler.
It would be nice if there was a Android-like "intent" system for add-ons so that Delete After Watching, Afterwatch, and FileCleaner could re-use code rather than all of us re-inventing it.
Reply
#12
Great addon script, exactly what I was looking for. The 'Select Series' is option is perfect, as I don't want my kids to be able to delete their shows accidentally.
Reply
#13
Very few of us would need the deletion to take place immediately after watching. Which I think might allow for a type of Undelete feature.

Could the "deletion request" just go into a queue to be actioned at a certain time, or after a certain time? That would allow for a reversal of the decision. I am picturing that you go into the Settings and open a window with the currently scheduled actions, and you could remove certain items if you wished.

If the actions are saved to a file, then the service could parse the file every 10-15 minutes, and delete the items that have passed expiry.
Reply
#14
download link is dead... pls reupload it for me Angel thank you !
Reply
#15
I have a script that functions similarly, I could release it if you are interested.

Sent from my SM-G935T
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply

Logout Mark Read Team Forum Stats Members Help
[WIP] Delete After Watching0