Giter Club home page Giter Club logo

skyhook's Introduction

Wrapper for the Sonarr Skyhook (TVDB API Wrapper)

How to install

Add Python 3.5 PPA

sudo add-apt-repository ppa:fkrull/deadsnakes

Install required packages
sudo apt-get update
sudo apt-get install git postgresql postgresql-contrib python3.5 python3.5-dev python-pip libpq-dev libxml2-dev libxslt1-dev
Grab source from GitHub
mkdir -p /opt/skyhook
git clone https://github.com/CmdrShepard/Skyhook.git /opt/skyhook
cd /opt/skyhook
Install virtualenv

sudo pip3 install virtualenv

######Create a virtualenv

virtualenv -p `which python3.5` venv
Install Skyhook

This might take a bit as LXML takes a while to build.

source venv/bin/activate
pip install uwsgi
pip install -e .
Open Postgres server
sudo su postgres
psql
Create Skyhook Postgres user and database
postgres=# CREATE USER skyhook WITH PASSWORD 'skyhook';
CREATE ROLE
postgres=# CREATE DATABASE skyhook;
CREATE DATABASE
postgres=# GRANT ALL PRIVILEGES ON DATABASE skyhook TO skyhook;
GRANT
postgres=# \q
exit
Configure Skyhook

Use the Postgres settings you set above for the DB_ items.

Generate an API key from TVDB:http://thetvdb.com/?tab=apiregister

sudo nano /opt/skyhook/src/instance/config.py

# DATABASE
SEARCH_CACHE_TIME = 86400
DB_HOST = 'localhost'
DB_USERNAME = 'skyhook'
DB_PASSWORD = 'skyhook'
DB_NAME = 'skyhook'
DB_PORT = 5432

# TVDB
# Get TVDB API Key here: http://thetvdb.com/?tab=apiregister
TVDB_API_KEY = None
TVDB_LANGUAGES = ['no', 'en']
Create a startup script

sudo nano /etc/init/skyhook.conf

description "uWSGI instance to serve Skyhook"

start on runlevel [2345]
stop on runlevel [!2345]

setuid www-data
setgid www-data

script
  cd /opt/skyhook/src    
  . ../venv/bin/activate
  uwsgi --ini skyhook.ini
end script
Start Skyhook

sudo start skyhook

For Nginx (preferred)

sudo nano /etc/nginx/sites-available/skyhook.sonarr.tv

server {
  listen 80;
  server_name skyhook.sonarr.tv;
  location / {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/skyhook.sock;
  }
}
sudo ln -s /etc/nginx/sites-available/skyhook.sonarr.tv /etc/nginx/sites-enabled/skyhook.sonarr.tv
sudo service nginx reload
For Apache2
sudo apt-get install libapache2-mod-wsgi
sudo nano /etc/apache2/sites-available/skyhook.sonarr.tv
<VirtualHost *:80>
  ServerName skyhook.sonarr.tv

  WSGIDaemonProcess skyhook python-path=/opt/skyhook/src:/opt/skyhook/venv/lib/python3.5/site-packages
  WSGIProcessGroup skyhook
  WSGIScriptAlias / /opt/skyhook/src/wsgi.py
</VirtualHost>
sudo a2ensite skyhook.sonarr.tv
sudo service apache2 restart
Edit host file

sudo nano /etc/hosts

# Sonarr
127.0.0.1 skyhook.sonarr.tv
Testing

By ID TVDB:

Game of Thrones: http://skyhook.sonarr.tv/v1/tvdb/shows/en/121361

Norske Rednecks: http://skyhook.sonarr.tv/v1/tvdb/shows/en/307674

Search:

Norske Rednecks: http://skyhook.sonarr.tv/v1/tvdb/search/en/?term=norske%20rednecks

skyhook's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

skyhook's Issues

New error on start

The config works great now. And skyhook is starting, but i get more errors when asking for something. Error below. Is it me missing something?


Starting uWSGI 2.0.14 (64bit) on [Tue Dec 6 13:44:20 2016] ***
compiled with version: 4.9.2 on 06 December 2016 09:13:14

os: Linux-3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02)
nodename: xxxxx
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /opt/skyhook/src
detected binary path: /opt/skyhook/venv2/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
your processes number limit is 15310
your memory page size is 4096 bytes
detected max file descriptor number: 65536
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/skyhook.sock fd 8
Python version: 3.5.2 (default, Dec 6 2016, 00:55:03) [GCC 4.9.2]


Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x15e92f0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
Starting Sonarr Skyhook v1.0.0
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x15e92f0 pid: 26343 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 26343)
spawned uWSGI worker 1 (pid: 26346, cores: 1)
2016-12-06 13:48:03,633 [skyhook.cache] [DEBUG] Trying to grab show from TV maze with TVDB ID: 307674
2016-12-06 13:48:04,291 [skyhook.tvdb] [DEBUG] Searching TVDB for ID=307674 and language "no"
Traceback (most recent call last):
File "/opt/skyhook/venv2/lib/python3.5/site-packages/tvdb_api.py", line 633, in _getetsrc
return ElementTree.fromstring(src)
File "/usr/local/lib/python3.5/xml/etree/ElementTree.py", line 1333, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 49

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/skyhook/venv2/lib/python3.5/site-packages/tvdb_api.py", line 637, in _getetsrc
return ElementTree.fromstring(src)
File "/usr/local/lib/python3.5/xml/etree/ElementTree.py", line 1333, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: syntax error: line 1, column 49

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/skyhook/venv2/lib/python3.5/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "./skyhook/views.py", line 70, in shows
cached_show = SonarrCache.get_cached_show(tvdb_id, language, True)
File "./skyhook/cache.py", line 261, in get_cached_show
search_result = handle_search(tvdb_id, search_results)[0]
File "./skyhook/cache.py", line 20, in handle_search
sonarr_format = tvdb.to_sonarr_format(result)
File "./skyhook/tvdb.py", line 157, in to_sonarr_format
show = self.tvdb[result['id']]
File "/opt/skyhook/venv2/lib/python3.5/site-packages/tvdb_api.py", line 948, in getitem
self._getShowData(key, self.config['language'])
File "/opt/skyhook/venv2/lib/python3.5/site-packages/tvdb_api.py", line 854, in _getShowData
self.config['url_seriesInfo'] % (sid, getShowInLanguage)
File "/opt/skyhook/venv2/lib/python3.5/site-packages/tvdb_api.py", line 645, in _getetsrc
self.config['cache_location']
KeyError: 'cache_location'
[pid: 26346|app: 0|req: 1/1] 127.0.0.1 () {38 vars in 911 bytes} [Tue Dec 6 13:48:03 2016] GET /v1/tvdb/shows/en/307674 => generated 0 bytes in 1586 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

Cant start skyhook

Hi. I cant get skyhook to start. This is the log:

*** Starting uWSGI 2.0.14 (64bit) on [Tue Dec 6 09:35:03 2016] ***
compiled with version: 4.9.2 on 06 December 2016 09:13:14
os: Linux-3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02)
nodename: xxxxxxx
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /opt/skyhook/src
detected binary path: /opt/skyhook/venv2/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
your processes number limit is 15310
your memory page size is 4096 bytes
detected max file descriptor number: 65536
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/skyhook.sock fd 8
Python version: 3.5.2 (default, Dec 6 2016, 00:55:03) [GCC 4.9.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x1615300
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
Traceback (most recent call last):
File "./wsgi.py", line 2, in
from skyhook import app
File "./skyhook/init.py", line 3, in
from instance.config import DebugConfig
ImportError: cannot import name 'DebugConfig'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 4453)
spawned uWSGI worker 1 (pid: 4455, cores: 1)
SIGINT/SIGQUIT received...killing workers...
worker 1 buried after 0 seconds
goodbye to uWSGI.
VACUUM: unix socket /tmp/skyhook.sock removed.

AttributeError: 'NoneType' object has no attribute 'split'

Hi Shepard.
We seem to be close to implementing this, but have an error we can't figure out how to resolve.
This is the log from testing a search using the test link in the readme.

Maybe Rodney can fix it? ;-)

(venv) root@skyhook:/opt/skyhook/src# uwsgi --ini skyhook.ini                                                                                                                                             
[uWSGI] getting INI configuration from skyhook.ini
*** Starting uWSGI 2.0.19 (64bit) on [Mon Jun 15 13:36:58 2020] ***
compiled with version: 9.3.0 on 14 June 2020 23:44:41
os: Linux-5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020
nodename: skyhook
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /opt/skyhook/src
detected binary path: /opt/skyhook/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
setgid() to 33
setuid() to 33
your processes number limit is 15212
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/skyhook.sock fd 3
Python version: 3.8.2 (default, Apr 27 2020, 15:53:34)  [GCC 9.3.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x56282f9fb7c0
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145808 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
Starting Sonarr Skyhook v1.0.0
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x56282f9fb7c0 pid: 33788 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 33788)
spawned uWSGI worker 1 (pid: 33791, cores: 1)

2020-06-15 13:37:37,266 [skyhook.views] [INFO] norske rednecks
2020-06-15 13:37:37,267 [skyhook.views] [DEBUG] Searching for norske rednecks
2020-06-15 13:37:37,279 [skyhook.cache] [DEBUG] Did not find any Sonarr cached search results for "norske rednecks" and language "en"                                                                     
2020-06-15 13:37:37,279 [skyhook.tvdb] [DEBUG] Searching TVDB for NAME="norske rednecks" and language "no"                                                                                                
Traceback (most recent call last):
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1477, in full_dispatch_request                                                                                                  
    rv = self.handle_user_exception(e)
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1381, in handle_user_exception                                                                                                  
    reraise(exc_type, exc_value, tb)
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1475, in full_dispatch_request                                                                                                  
    rv = self.dispatch_request()
  File "/opt/skyhook/venv/lib/python3.8/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "./skyhook/views.py", line 61, in search
    sonarr_results = handle_results(search_string, language)
  File "./skyhook/views.py", line 28, in handle_results
    results = tvdb.search(search_string, language)
  File "./skyhook/tvdb.py", line 137, in search
    results = self.tvdb.search(string)
  File "/opt/skyhook/venv/lib/python3.8/site-packages/tvdb_api.py", line 706, in search
    result['aliasnames'] = result['aliasnames'].split("|")
AttributeError: 'NoneType' object has no attribute 'split'
[pid: 33791|app: 0|req: 1/1] 10.0.0.4 () {40 vars in 980 bytes} [Mon Jun 15 13:37:37 2020] GET /v1/tvdb/search/en/?term=norske%20rednecks => generated 0 bytes in 64 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)

Skyhook not serving the right episodes for DuckTales (2017)

The issue is described in https://www.reddit.com/r/sonarr/comments/k2p185/phantom_ducktales_2017_episode_in_sonarr_only/

Essentially for DuckTales (2017) season 3 Sonarr displays E12 (as per TVDB & TMDB) as split into Part 1 (E12) and Part 2 (E13).
This then offsets all the following episodes (e.g. E13 becomes E14, etc) creating issues with managing the series.

RhynoRys pointed out that this is not an issue with waiting for 24h for Skyhook to match TVDB as (quoting his post)

TheTVDB has this tagged as last edited on October 5th so waiting wont help, I've also checked with my own API key and its not showing in the data. Sonarr actually downloads from skyhook which is their own personal cache of the TVDB to reduce the API traffic. This episode is on there. Its also on the "intended viewing order" of season 3 on theTVDB rather than the "aired order" you were looking at.
Heres the skyhook link if you care to read through the JSON code.
http://skyhook.sonarr.tv/v1/tvdb/shows/en/330134

Thank you for your help

Error: could not determine PostgreSQL version from '11.7' (Debian 10)

Hi.
We are trying to install this on Debian 10 and have problems.
It halts with the error in title:

These are the commands we used to install dependencies, in case it matters.
(We prefer packaged versions over pip-versions)

apt install postgresql postgresql-contrib python3.7 python3.7-dev python3-pip libpq-dev libxml2-dev libxslt1-dev
apt install virtualenv
apt install uwsgi
source venv/bin/activate
pip3 install -e .                                                                                                                                                                                        
Obtaining file:///opt/skyhook
Collecting Flask==0.10.1
  Using cached Flask-0.10.1.tar.gz (544 kB)
Collecting Flask-SQLAlchemy==2.1
  Using cached Flask-SQLAlchemy-2.1.tar.gz (95 kB)
Collecting lxml==3.6.0
  Using cached lxml-3.6.0.tar.gz (3.7 MB)
Collecting psycopg2==2.6.1
  Using cached psycopg2-2.6.1.tar.gz (371 kB)
    ERROR: Command errored out with exit status 1:
     command: /opt/skyhook/venv/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-90_h7q_p/psycopg2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-90_h7q_p/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-sfme3224                                              
         cwd: /tmp/pip-install-90_h7q_p/psycopg2/
    Complete output (7 lines):
    running egg_info
    creating /tmp/pip-pip-egg-info-sfme3224/psycopg2.egg-info
    writing /tmp/pip-pip-egg-info-sfme3224/psycopg2.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-pip-egg-info-sfme3224/psycopg2.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-pip-egg-info-sfme3224/psycopg2.egg-info/top_level.txt
    writing manifest file '/tmp/pip-pip-egg-info-sfme3224/psycopg2.egg-info/SOURCES.txt'
    Error: could not determine PostgreSQL version from '11.7'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

TVDB Broadcast vs DvD Order

Would it be possible to get the DVD order pulled as well in the query?

I use https://www.thetvdb.com/series/fortitude as an example where the DVD version split episode 1 into 2 parts and thus had a 12 episode season 1 but only 11 episodes aired.

There are many more use cases for this.

Sonarr/Sonarr#255

Sonarr has closed the issue due to being blocked by skyhook, so working up the chain in an effort to fix this

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.