Jump to content


Photo

Emby Media Clean - Delete Watched Video


  • Please log in to reply
25 replies to this topic

#1 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 18 September 2019 - 06:52 PM

Hi, I created a python script that will look for all watched content for a specific user. If the last played date is past the cut off date it will delete the file.

I built this for myself and it works good enough for me, but I have only tested it on my system (ubuntu 18.04) with my server. So no guarantee it will work for everyone, and since it can delete files have a backup to be safe. By default it does not delete files until you modify the config file to be safer.

It first lists all the files, then will list the files that will be deleted.

On first run it will ask you some questions to generate the config file, or you can create it manually

Here is the script if anyone else is interested in trying it out: https://github.com/c...j/media_cleaner


  • hieroglyph, Kurosh and Crowley_00 like this

#2 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 18 September 2019 - 07:51 PM

Kurosh asked for the ability to treat TV vs Movies different.

 

For my use case I don't care and delete all files the same.  But I will try to add the ability to configure if you want Episodes, Movies or Videos to be deleted or ignored.


  • Kurosh likes this

#3 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 18 September 2019 - 08:31 PM

I have pushed the new version.  Config file will need to be re-generated.  You can now have the following three options

 

video_action='delete'
movie_action='delete'
episode_action='delete'

 

Anything other then delete will ignore that content type.


  • Kurosh likes this

#4 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 142356 posts
  • Local time: 11:33 AM

Posted 18 September 2019 - 09:33 PM

Cool, thanks for sharing.

#5 mastrmind11 OFFLINE  

mastrmind11

    Advanced Member

  • Members
  • 2837 posts
  • Local time: 11:33 AM
  • LocationLong Island, NY

Posted 19 September 2019 - 06:28 AM

@Luke, what is the timeframe to get something like this bundled w/ Emby?  I know it's been a FR for quite some time (2 years now?).  The ability to remove watched episodes at the series level is the most basic DVR feature out there.



#6 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 142356 posts
  • Local time: 11:33 AM

Posted 19 September 2019 - 12:24 PM

This exact script isn't getting bundled. We would just do our feature for it.



#7 Kurosh OFFLINE  

Kurosh

    Advanced Member

  • Members
  • 47 posts
  • Local time: 05:33 PM

Posted 24 September 2019 - 06:35 AM

I have pushed the new version.  Config file will need to be re-generated.  You can now have the following three options

 

video_action='delete'
movie_action='delete'
episode_action='delete'

 

Anything other then delete will ignore that content type.

Thanks for this, so "movie_action" = movies and "episode_action" = TV shows. Therefore what is "video_action"?



#8 Kurosh OFFLINE  

Kurosh

    Advanced Member

  • Members
  • 47 posts
  • Local time: 05:33 PM

Posted 24 September 2019 - 06:36 AM

This exact script isn't getting bundled. We would just do our feature for it.

Any idea on a timeframe for this feature though? The feature was initially requested in June 2014 :)


Edited by Kurosh, 24 September 2019 - 06:56 AM.


#9 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 142356 posts
  • Local time: 11:33 AM

Posted 24 September 2019 - 12:01 PM

Not yet, sorry.



#10 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 24 September 2019 - 08:22 PM

Thanks for this, so "movie_action" = movies and "episode_action" = TV shows. Therefore what is "video_action"?

 

video is for things in the home video or other video category.  I use that for random videos I download off the internet like youtube videos where I don't have metadata for.



#11 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 27 October 2019 - 06:56 PM

I have pushed a couple of new updates.  Some users were getting error depending on the results their servers were returning.  That should all be fixed now, if anyone is still getting errors let me know.

 

I also added a new option to ignore favorite files so they don't get deleted.



#12 anian OFFLINE  

anian

    Newbie

  • Members
  • 1 posts
  • Local time: 06:33 PM

Posted 04 November 2019 - 06:03 AM

Hello.

May you add an option to exclude some libraries. Like classic movie that I download to left for all times.



#13 Michael Poulsen OFFLINE  

Michael Poulsen

    Member

  • Members
  • 25 posts
  • Local time: 05:33 PM

Posted 15 November 2019 - 01:31 PM

excactly what i have been looking for, but it trows me this error in debian stretch (openmediavault)

 

i have both python 2.7 ant python 3 an have tried running with python3 command (Anyone that can help me)

 

 Traceback (most recent call last):
  File "./media_cleaner.py", line 154, in <module>
    import media_cleaner_config as cfg
ImportError: No module named 'media_cleaner_config'
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "./media_cleaner.py", line 162, in <module>
    except (AttributeError, ModuleNotFoundError):
NameError: name 'ModuleNotFoundError' is not defined


#14 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 16 November 2019 - 02:21 PM

Can you try downloading the latest version from git and trying again.  I can't seem to re-create this issue.

 

Also, can you let me know what version of python3 you are using with the following: python3 --version



#15 Michael Poulsen OFFLINE  

Michael Poulsen

    Member

  • Members
  • 25 posts
  • Local time: 05:33 PM

Posted 17 November 2019 - 12:05 PM

python 3.5.3



#16 Michael Poulsen OFFLINE  

Michael Poulsen

    Member

  • Members
  • 25 posts
  • Local time: 05:33 PM

Posted 17 November 2019 - 12:10 PM

python 3.5.3

this is the exact error

 

python3 /srv/dev-disk-by-label-Data/Scripts/media_cleaner.py
Traceback (most recent call last):
  File "/srv/dev-disk-by-label-Data/Scripts/media_cleaner.py", line 154, in <module>
    import media_cleaner_config as cfg
ImportError: No module named 'media_cleaner_config'
 
During handling of the above exception, another exception occurred:
 
Traceback (most recent call last):
  File "/srv/dev-disk-by-label-Data/Scripts/media_cleaner.py", line 162, in <module>
    except (AttributeError, ModuleNotFoundError):
NameError: name 'ModuleNotFoundError' is not defined


#17 Michael Poulsen OFFLINE  

Michael Poulsen

    Member

  • Members
  • 25 posts
  • Local time: 05:33 PM

Posted 17 November 2019 - 12:13 PM

maybe because i have both python 3 and python 2.7, but have many other things that require 2.7



#18 Crowley_00 OFFLINE  

Crowley_00

    Newbie

  • Members
  • 4 posts
  • Local time: 06:33 PM

Posted 18 November 2019 - 01:28 PM

Thank you for this, just what I needed. One thing I think would be useful is logging to a file with an indicator how many days ago a file was watched. The current date format in the output when running the script is kind of hard to read.



#19 jpc82 OFFLINE  

jpc82

    Member

  • Members
  • 18 posts
  • Local time: 11:33 AM

Posted 19 November 2019 - 06:52 AM

@Michael sorry but I can't seem to re-create the issue your having.  Are you using Windows, Linux or Mac?

 

@Crowley_00 I can look into creating a log file.  So your looking for a log file that just appends the file name, date watched for any file deleted.  I assume you would want the log file to append between runs.



#20 Crowley_00 OFFLINE  

Crowley_00

    Newbie

  • Members
  • 4 posts
  • Local time: 06:33 PM

Posted 19 November 2019 - 07:12 AM

I like to automate everything and logs help me check what the scripts have been doing.
 
I think it would be useful to list all the watched files, and separate deleted. Something like:
 
Time ran
 
Watched:
 
Series X S01E01 (7 days ago)
Series X S01E02 (6 days ago)
Series X S01E03 (5 days ago)
 
Deleted: 
 
Series X S01E01 (7 day setting in the config file)
 
Append would be fine, I could always delete the log if it gets too big. So pretty similar what the script outputs now but a little easier to read. Right now it does not seem to show series name and the date format could be simpler.
 
But this is all just wishful thinking, the script is working fine for me as is. Thanks again!

Edited by Crowley_00, 19 November 2019 - 07:13 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users