Coder Social home page Coder Social logo

pingrr's Introduction

Check out traktarr https://github.com/l3uddz/traktarr for a cool alternative if pingrr isn't for you

alt text

pingrr.

Python script that checks certain lists on Trakt and Netflix's recently added shows/movies, as well as JustWatch's recent shows/movies and if they meet your configured filters, adds them to your sonarr/radarr library.

Currently supports:

  1. Trakt Trending
  2. Trakt Anticipated
  3. Trakt Popular
  4. Netflix recently added # Currently not supported, use justwatch
  5. Just Watch recently added

Getting Started

You will need a trakt.tv account with a Trakt API key, as well as your Sonarr API.

Quick warning when setting up the script. If you activate lots of lists with no filters, you will get a lot of shows that you may not want. At a minimum, it is recommended to use the language code filter and limit shows added per run.

Prerequisites

You will need a Trakt account and an API key (client ID), you can create a new API app in trakt here

  1. Python 2.7
  2. requests
  3. BeautifulSoup
  4. fuzzywuzzy
  5. ImdbPY

sudo apt-get install python

pip install -r requirements.txt

Installing

git clone https://github.com/Dec64/pingrr.git

cd pingrr

python pingrr.py

Follow the instructions in the console to complete the configuration file. This is only needed on the first run. Once complete you will need to re-run Pingrr.

python pingrr.py

If you intend to leave it running, it would be best to use systemd startup or screen.

screen -S pingrr python pingrr.py

Check it's all running fine by tailing the log

tail -f logs/pingrr.log

Command line arguments

If you want to define a config location for pingrr (running multiple instances with different categories/folder locations/lists) you can define the config location via:

  • Command line by using -c or --config=:

    • python pingrr.py -c /my/config/location/conf.json
    • python pingrr.py --config=/my/config/location/conf.json
  • Environment variable by setting PINGRR_CONFIG:

    • PINGRR_CONFIG=/my/config/location/conf.json python pingrr.py

Logging level can be increased if you are having issues and want more output in the log/console by using --loglevel:

  • python pingrr.py --loglevel=DEBUG

To list all possible arguments and options run:

  • python pingrr.py -h

Blacklist

There is a blacklist.json file created on the first run. This file will have failed shows and any show you want to add to it outside of filters that you never want to add. To add a show, either use the shows IMDB id or TVDB id.

{"blacklist": ["imdb id", "or tvdb id", "332493", "75760", "79168", "334069"]}

Just Watch

https://www.justwatch.com/

Early support for justwatch is included.

    "just_watch": {
        "enabled": true,
        "country": "GB",
        "pages": "1"
    }

Each page is a single day, so if you set 1 page, it will check against all services justwatch supports in your chosen country for the last day.

Set more pages to scan back more days, doing this will cause the scan to take longer and potentially add a lot of shows.

Should support any two-letter country code that Just Watch has data for.

E.g:

Germany
Austria
Switzerland
United Kingdom
Ireland
Russia
Italy
France
Spain
Netherlands
Norway
Sweden
Denmark
Finland
Lithuania
Latvia
Estonia
USA
Canada
Mexico

and more

Config

There are a few config settings that are not set by the user on the first run if you fancy messing with more advanced settings you can open up the config.json file and change as needed.

Please see below for an explanation for the current config

{
    "allflicks": {
        "enabled": {
            "movies": true,
            "shows": false
        },
        "rating_match": 94
    },
    "filters": {
        "allow_canceled": true, ## allow shows that are cancelled to be added
        "allow_ended": true, ## allow shows that are finished to be added
        "country": ["gb","us","ca"], ## What countrys shows/movies are allowed to be from (whitelist)
        "genre": [], ## What genres shows/movies are NOT allowed to be from (blacklist)
        "language": "en", ## What language is allowed for shows/movies (whitelist)
        "network": "YouTube", ## What networks to NOT allow (blacklist)
        "rating": 3, ## Min rating show/movie must have to be added
        "runtime": 0, ## Min runtime show/movie must have to be added
        "votes": 1, ## Min votes show/movie must have to be added
        "year": {
            "movies": 0, ## Min year movie must be to be added
            "shows": 0 ## Min year show must be to be added
        }
    },
    "pingrr": {
        "limit": {
            "sonarr": 0, ## Amount of shows to be added per cycle
            "radarr": 0 ## Amount of movies to be added per cycle
        },
        "log_level": "info", ## Log level for pingrr
        "timer": 1.00, ## How long to wait, in hours, untill next scan
        "aired": 10 ## If show has less episodes then this aired, do not count towards limit
        "dry_run": False ## Set to true to not add any shows, just test filter results
    },
    "pushover": {
        "app_token": "",
        "enabled": true,
        "user_token": ""
    },
    "slack": {
        "channel": "",
        "enabled": false,
        "sender_icon": ":robot_face:",
        "sender_name": "Pingrr",
        "webhook_url": ""
    },
    "sonarr": {
        "api": "",
        "folder_path": "/mnt/media/TV/", ## Default root folder path shows will be sent to
        "quality_profile": 1, ## Quality profile ID to assign to show in sonarr
        "monitored": true, ## Add show monitored or not
        "search_missing_episodes": true, ## Search for missing episodes on add or not
        "genre_paths": true, ## Use genre paths, change folder path for show depending on catagory
        "path_root": "/mnt/media/", ## Root of the path. Only need if using genre paths
        "paths": {  ## "Kids-TV": [children] == /mnt/media/Kids-TV for any show with genre "children". Add more as needed. Resolves in order. If show is Anime, will be sent to anime before Kids-TV in this example.
            "Anime": [
            "anime"
        ],
            "Kids-TV": [
            "children"
        ],
            "Travel-TV": [
            "documentary"
        ],
            "Reality-TV": [
            "reality",
                "game-show"
        ]
        }
    },
        "radarr": {
        "api": "",
        "folder_path": "/mnt/media/Movies/",
        "host": "http://localhost:7878",
        "quality_profile": 1,
        "monitored": true,
        "genre_paths": true,
        "path_root": "/mnt/media/",
        "paths": {
            "Anime": [
            "anime"
        ],
            "Kids-TV": [
            "children"
        ],
            "Travel-TV": [
            "documentary"
        ],
            "Reality-TV": [
            "reality",
                "game-show"
        ]
        }
    },
    "trakt": {
        "api": "", ## Client ID from trakt
        "imdb_info": false, ## Use imdb info for votes/genres/vote count if possible instead of trakt. WARNING, MUCH SLOWER THEN TRAKT.
        "limit": 2000, ## Max shows trakt will return. Use a higher number, e.g. 1000 to return a lot.
        "tv_list": {
            "anticipated": false,  ## Enable trakt tv anticipated
            "popular": false,	## Enable trakt tv popular
            "trending": false	## Enable trakt tv trending
        },
        "movie_list": {
            "anticipated": true, ## Enable trakt movie anticipated
            "popular": true, ## Enable trakt movie popular
            "trending": true ## Enable trakt movie trending
        }
    },
    "just_watch": {
        "enabled": {
            "movies": true, ## Enable justwatch for movies
            "shows": false ## Enable justwatch for shows
        },
        "country": "GB", ## What country to get justwatch info based on, e.g. GB or US
        "pages": "20" ## How many pages to get info from, 1 page = 1 day. Add more pages to add more content. Will be slower with more pages
    }
}
"rating_match":94

How close the match has to be out of 100 when parsing Netflix titles. If you feel you are missing some titles feel free to play with this figure, but anything lower then 90 will most likely result in incorrect matches.

For the unwanted genres list, you need to type them as found on IMDB, here are some examples:

comedy
action
drama
fantasy
science-fiction
adventure
reality
superhero
crime
mystery
horror
thriller
romance
animation
children
home-and-garden
anime
family
documentary
game-show
suspense

Start on boot

To have pingrr start on boot on Ubuntu

cd /opt

git clone https://github.com/Dec64/pingrr.git

run pingrr, and complete the config.

sudo nano /etc/systemd/system/pingrr.service

copy and paste the below, after editing User= and Group=

[Unit]
Description=pingrr
After=network-online.target

[Service]
User=YOUR_USER
Group=YOUR_USER
Type=simple
WorkingDirectory=/opt/pingrr/
ExecStart=/usr/bin/python /opt/pingrr/pingrr.py
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

Then enabled and start it with:

sudo systemctl enable pingrr.service

sudo systemctl start pingrr


If you are have set pingrr to not loop (setting the timer to 0) then you must remove Restart=always RestartSec=10 from systemd file, otherwise, it will restart every 10 seconds.

Todo

  1. Learn python

Thanks

Thanks to horjulf and l3uddz for assisting me with a few bits so far, and everyone that helped test it along the way.

If you have any suggestions for features ect feel free to create a new issue on GitHub for it!

Donate

If you absolutely feel the need to donate, the link is below. Pull requests and help cleaning up my amateur python would be more helpful :)

paypal

pingrr's People

Contributors

dec64 avatar horjulf avatar vertigo235 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pingrr's Issues

Add To blacklist

Be nice to add a show to a blacklist so its not put into sonarr or radarr:)

Feature request: blacklist_title_keywords

Getting tons of WWE and UFC shows despite sports in blacklisted to overcome it the easiest way would be to add in config

      "blacklist_title_keywords": [
        "wwe",
        "ufc" ]

Demo/Dry Run Mode?

Hi there,

Thanks for the great code! This is exactly what I was looking for.

I would like to suggest that you add a dry run/testing mode so we can play with different settings and see what kind of shows are picked up without actually adding them to Sonarr.

Issue + Suggestion

Hi,

first of all THANK YOU for this tool.

I just started using it and I noticed that justwatch don't work if you change language (IT in my case).

The reason is that API call is set to

https://apis.justwatch.com/content/providers/locale/en_LANGUAGE

while for IT country should be the following

https://apis.justwatch.com/content/providers/locale/it_IT

Moreover there's a way to filter providers?

I only have Amazon Video and Netflix and I would love to add contents available only with those services.

Thank you in advance

radarr on windows?

Hi m8ty, thought today would try allowing your script to connect to radarr. put in correct info in config, but its throwing this error:

Traceback (most recent call last):
File "pingrr.py", line 424, in
radarr_library = radarr.get_library()
File "D:\Appz\pingrr\pingrr\radarr.py", line 50, in get_library
r = requests.get(url + '/api/movie', headers=headers, timeout=60)
File "C:\Python27\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 612, in send
adapter = self.get_adapter(url=request.url)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 703, in get_adapter
raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'localhost:7878/api/movie'

wont run

THis is a modulae ive been looking for for AGES!!! so I hope we can get it working:)

Im on windowsserver 2008
python 27
all requirements are running 100% shown below:
D:\Appz\pingrr>pip install -r requirements.txt
Requirement already satisfied: requests~=2.18.4 in c:\python27\lib\site-packages (from -r requirements.txt (line 1))
Requirement already satisfied: BeautifulSoup4~=4.6.0 in c:\python27\lib\site-packages (from -r requirements.txt (line 2))
Requirement already satisfied: fuzzywuzzy~=0.15.1 in c:\python27\lib\site-packages (from -r requirements.txt (line 3))
Requirement already satisfied: python-Levenshtein~=0.12.0 in c:\python27\lib\site-packages (from -r requirements.txt (line 4))
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\python27\lib\site-packages (from requests~=2.18.4->-r requirements.txt (line 1))
Requirement already satisfied: certifi>=2017.4.17 in c:\python27\lib\site-packages (from requests~=2.18.4->-r requirements.txt (line 1))
Requirement already satisfied: urllib3<1.23,>=1.21.1 in c:\python27\lib\site-packages (from requests~=2.18.4->-r requirements.txt (line 1))
Requirement already satisfied: idna<2.7,>=2.5 in c:\python27\lib\site-packages (from requests~=2.18.4->-r requirements.txt (line 1))
Requirement already satisfied: setuptools in c:\python27\lib\site-packages (from python-Levenshtein~=0.12.0->-r requirements.txt (line 4))

When i run first time, it askes me the questions to generate the config, but at the end it throws an error without creating the config file and i see some errors below:

Do you want to use Trakt's anticipated list? (yes/no):
yes
�[94mTrue�[0m

Do you want to use Trakt's popular list? (yes/no):
yes
�[94mTrue�[0m

What is the minimum number of votes for a show to be grabbed?:

�[94m�[0m

At the end of answering all the config questions i see:

Traceback (most recent call last):
File "pingrr.py", line 45, in
configuration.load()
File "D:\Appz\pingrr\pingrr\config.py", line 169, in load
self.create_config(self.settings['config'])
File "D:\Appz\pingrr\pingrr\config.py", line 447, in create_config
"runtime": int(filters_runtime),
ValueError: invalid literal for int() with base 10: ''

When i try running the script i get below error:

D:\Appz\pingrr>python pingrr.py
2018-03-04 16:21:39,349 pingrr.config INFO Using default setting --loglevel=INFO
2018-03-04 16:21:39,351 pingrr.config INFO Using default setting --blacklist=blacklist.json
2018-03-04 16:21:39,351 pingrr.config INFO Using default setting --logfile=logs\pingrr.log
2018-03-04 16:21:39,351 pingrr.config INFO Using default setting --config=config.json
Traceback (most recent call last):
File "pingrr.py", line 45, in
configuration.load()
File "D:\Appz\pingrr\pingrr\config.py", line 165, in load
self.config = json.load(f)
File "C:\Python27\lib\json_init_.py", line 291, in load
**kw)
File "C:\Python27\lib\json_init_.py", line 339, in loads
return _default_decoder.decode(s)
File "C:\Python27\lib\json\decoder.py", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Python27\lib\json\decoder.py", line 380, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 10 column 33 (char 191)

Any hlpe would be appreciated:)

paths on windows

Soz to bother you again, but ran into another problem and im sure its my fault, but no sure why paths is an issue. In your log:

2018-03-05 13:48:18,661 root INFO Attempting to send to sonarr
2018-03-05 13:48:19,134 root WARNING Deception failed to be added to Sonarr! Adding to blacklist
2018-03-05 13:48:19,134 root INFO Attempting to send to sonarr
2018-03-05 13:48:19,414 root WARNING Rise failed to be added to Sonarr! Adding to blacklist
2018-03-05 13:48:19,414 root INFO Attempting to send to sonarr
2018-03-05 13:48:19,686 root WARNING American Woman failed to be added to Sonarr! Adding to blacklist
2018-03-05 13:48:19,687 root INFO Attempting to send to sonarr
2018-03-05 13:48:19,961 root WARNING The Launch failed to be added to Sonarr! Adding to blacklist
2018-03-05 13:48:19,963 root INFO Attempting to send to sonarr
2018-03-05 13:48:20,223 root WARNING Vida failed to be added to Sonarr! Adding to blacklist

Your scripts tried to add the 5 tvshow into sonarr however in sonarr log, I get:

Invalid request Validation failed:
-- Invalid Path

in my config the sonarr paths are:

"sonarr": {
"api": "3d84f93XXXXXXXX",
"folder_path": "D:/Media/Current/Series Source",
"genre_paths": false,
"host": "http://localhost:8989",
"monitored": true,
"path_root": "D:/Media/Current",
"paths": {
"Anime": [
"anime"
],
"Doc-TV": [
"documentary"
],
"Kids-TV": [
"children, family"
],
"Reality-TV": [
"reality",
"game-show"
]
},

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.