blacktwin / JBOPS

Just a Bunch Of Plex Scripts
1.7k stars 305 forks source link

Help with find_unwatched.py #113

Closed mizled closed 5 years ago

mizled commented 5 years ago

I am trying to use your find_unwatched.py script but getting the below error. Any help would be appreciated.

I am using Tautulli V2.1.25

Tautulli API 'get_libraries_table' request failed: No JSON object could be decoded.Traceback (most recent call last): File "find_unwatched.py", line 130, in <module> glt = [lib for lib in get_libraries_table()] TypeError: 'NoneType' object is not iterable

blacktwin commented 5 years ago

Check your API and URL.

mizled commented 5 years ago

Thanks, they are correct. Here is an example of what I am using there. I removed the API key but it is correct. I am running the script from the server hosting Tautulli by running the command "python find_unwatched.py" and the file has execute permissions.

## EDIT THESE SETTINGS ## TAUTULLI_APIKEY = 'xxx' # Your Tautulli API key TAUTULLI_URL = 'http://localhost:8181/' # Your Tautulli URL LIBRARY_NAMES = ['Movies'] # Name of libraries you want to check.

blacktwin commented 5 years ago

I was able to reproduce the error with an incorrect API. Maybe generate a new? I'm pretty sure it's your API key.

mizled commented 5 years ago

Sorry I resolved the issue myself. I am using a a base URL of /tautulli/ and once I added that it is now working.

Is there a way with this script to go line by line of each and only delete certain ones? Or is there a way to add an exception for certain files I do not want to delete but haven't been watched?

blacktwin commented 5 years ago

Is there a way with this script to go line by line of each and only delete certain ones? Or is there a way to add an exception for certain files I do not want to delete but haven't been watched?

@mizled yeah. you'd need to modify the deletion function. Currently:

def delete_files(tmp_lst):
    del_file = raw_input('Delete all unwatched files? (yes/no)').lower()
    if del_file.startswith('y'):
        for x in tmp_lst:
            print("Removing {}".format(x))
            os.remove(x)
    else:
        print('Ok. doing nothing.')

Modify:

def delete_files(tmp_lst):
    for x in tmp_lst:
        del_file = raw_input('Delete unwatched file {}? (yes/no)'.format(x)).lower()
        if del_file.startswith('y'):
            print("Removing {}".format(x))
            os.remove(x)
        else:
            print('Ok. doing nothing.')

something like that. So that it would go through the list of unwatched content and ask you Yes/No for each.