Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overseerr support #210

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
35ff610
v1.6.4 Merge
dirtycajunrice Feb 4, 2019
d274df3
Merge pull request #115 from Boerderij/develop
samwiseg0 Mar 11, 2019
9590839
Merge pull request #116 from Boerderij/develop
samwiseg0 Mar 12, 2019
702c86d
v1.6.7 Merge
dirtycajunrice Apr 18, 2019
bc8565f
link change
dirtycajunrice Apr 18, 2019
379117d
v1.6.8 Merge
dirtycajunrice Apr 19, 2019
6d61515
v1.7.0 Merge
dirtycajunrice May 6, 2019
5570721
Merge pull request #134 from Boerderij/develop
dirtycajunrice Jun 4, 2019
73410db
v1.7.2 Merge
dirtycajunrice Jun 24, 2019
f3286ca
v1.7.3 Merge
dirtycajunrice Aug 9, 2019
86ba4f2
Merge pull request #155 from Boerderij/develop
dirtycajunrice Oct 7, 2019
7b71a8a
v1.7.5
dirtycajunrice Dec 11, 2019
b3b1876
v1.7.6 (#165)
samwiseg0 Jan 2, 2020
23bcbbf
v1.7.7
dirtycajunrice Dec 21, 2020
50302c8
add branch to build inputs
dirtycajunrice Dec 21, 2020
ec79d22
update pipeline badge
dirtycajunrice Dec 21, 2020
12c2a57
Add influxdb 2 client
gcrevell Feb 13, 2021
59d6821
Add structure for influxdb 2 params
gcrevell Feb 13, 2021
5b15299
Parse influxdb 2 config data
gcrevell Feb 13, 2021
6d170c1
Add influxdb2 manager class
gcrevell Feb 13, 2021
364253e
Use the correct db manager for varken
gcrevell Feb 13, 2021
06e6a0f
Add influxdb2 to the example varken config file
gcrevell Feb 13, 2021
1a712ab
Create influx bucket if it doesn't exist
gcrevell Feb 13, 2021
ede4762
Update InfluxDB type on README
gcrevell Feb 13, 2021
a78da12
Clean up linting errors
gcrevell Feb 13, 2021
b4efd15
Wrap create bucket in try/catch
gcrevell Feb 13, 2021
ac25883
Use bucket given in ini file
gcrevell Mar 1, 2021
6b91b8c
Initial testing of Overseerr API integration
Aug 4, 2021
909d7ff
updated indent
Aug 4, 2021
b7956ca
updated another indent
Aug 4, 2021
a6453f8
missed some excepts it looks like
Aug 4, 2021
1207440
added correct imports
Aug 4, 2021
69b1d0d
added OverseerrServer structure to iniparser
Aug 4, 2021
8045e46
added globals section
Aug 4, 2021
3ded1f9
updated variable names
Aug 4, 2021
9a96ae7
updated variables again
Aug 4, 2021
25bd8c1
updated variable names again
Aug 4, 2021
5989a94
variable names are awesome
Aug 4, 2021
6912e22
convert my shitty javascript code to python code megalul
Aug 4, 2021
78bc43f
more converting javascript syntax to python
Aug 4, 2021
b0e74c9
change variable name
Aug 4, 2021
c933501
updated error log code
Aug 4, 2021
c247c16
updated structures to match output from overseerr api
Aug 4, 2021
768b9f0
added support for request counts
Aug 4, 2021
78af866
forgot to import
Aug 4, 2021
0e8694e
testing out get_latest_requests
Aug 4, 2021
679d725
messed up a simple print command, I don't know python very well
Aug 4, 2021
10c9394
converting int to str
Aug 4, 2021
4fa9f5f
tuple issues
Aug 4, 2021
9b4c14d
more tuple issues
Aug 4, 2021
2b9f057
more int conversions
Aug 4, 2021
4cf29c8
more testing
Aug 4, 2021
d7e96f5
messed up my endpoints
Aug 4, 2021
3914f41
still messing up my endpoints
Aug 4, 2021
50944c9
lets try and write some stuff
Aug 4, 2021
f0ead6d
again
Aug 4, 2021
3b07af0
disable hasing for now
Aug 4, 2021
02cf99f
forgot to have it write data
Aug 4, 2021
35559a9
putting in dummy data
Aug 4, 2021
ba454b0
try this method of hashit
Aug 4, 2021
b23e68e
yup updating all hashits
Aug 4, 2021
a21ebcc
try simplifying it
Aug 4, 2021
1f4f351
testing
Aug 4, 2021
ea1c4f9
more testing
Aug 4, 2021
d1ed42f
should be fully working now
Aug 4, 2021
0874ef1
final cleanup and commit and test
Aug 4, 2021
52e758f
Add overseerr support
Aug 4, 2021
07cc594
Printing result to see what we're getting
Aug 29, 2021
ad7e048
Merge branch 'overseerr' of https://github.com/t0phux/Varken into ove…
Aug 29, 2021
4953066
Merge branch 'develop' into overseerr
samwiseg0 Dec 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Change Log

## [v1.7.7](https://github.com/Boerderij/Varken/tree/v1.7.7) (2020-12-21)
[Full Changelog](https://github.com/Boerderij/Varken/compare/1.7.6...v1.7.7)

**Implemented enhancements:**
- \[Enhancement\] Ombi 4.0 compatibility [\#186](https://github.com/Boerderij/Varken/issues/186)
([samwiseg0](https://github.com/samwiseg0))

**Merged pull requests:**

- v1.7.7 Merge [\#191](https://github.com/Boerderij/Varken/pull/191)
([DirtyCajunRice](https://github.com/DirtyCajunRice))
- Type Error fix [\#177](https://github.com/Boerderij/Varken/pull/177)
([derek-miller](https://github.com/derek-miller))

**Fixed bugs:**

- \[BUG\] Influxdb exit code [\#174](https://github.com/Boerderij/Varken/issues/174)
([samwiseg0](https://github.com/samwiseg0))

**Notes:**
- Now built via github actions
- Available on ghcr, quay.io, and dockerhub
- Nightly builds done to accommodate dependabot MRs

## [v1.7.6](https://github.com/Boerderij/Varken/tree/v1.7.6) (2020-01-01)
[Full Changelog](https://github.com/Boerderij/Varken/compare/1.7.5...v1.7.6)

Expand Down Expand Up @@ -350,4 +374,4 @@
- Create crontabs [\#6](https://github.com/Boerderij/Varken/pull/6) ([ghost](https://github.com/ghost))
- update plex\_dashboard.json [\#5](https://github.com/Boerderij/Varken/pull/5) ([ghost](https://github.com/ghost))
- Update README.md [\#4](https://github.com/Boerderij/Varken/pull/4) ([ghost](https://github.com/ghost))
- added sickrage portion [\#3](https://github.com/Boerderij/Varken/pull/3) ([ghost](https://github.com/ghost))
- added sickrage portion [\#3](https://github.com/Boerderij/Varken/pull/3) ([ghost](https://github.com/ghost))
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img width="800" src="https://raw.githubusercontent.com/Boerderij/Varken/master/assets/varken_full_banner.jpg" alt="Logo Banner">
</p>

[![pipeline status](https://gitlab.com/boerderij/Varken/badges/master/pipeline.svg)](https://gitlab.com/boerderij/Varken/commits/master)
[![pipeline status](https://img.shields.io/github/workflow/status/Boerderij/Varken/varken?style=flat-square)](https://github.com/Boerderij/Varken/actions?query=workflow%3Avarken)
[![Discord](https://img.shields.io/discord/518970285773422592.svg?colorB=7289DA&label=Discord&logo=Discord&logoColor=7289DA&style=flat-square)](https://discord.gg/VjZ6qSM)
[![ko-fi](https://img.shields.io/badge/Buy%20Us%20A%20Coffee-Donate-ff813f.svg?logo=CoffeeScript&style=flat-square)](https://ko-fi.com/varken)
[![Docker-Layers](https://images.microbadger.com/badges/image/boerderij/varken.svg)](https://microbadger.com/images/boerderij/varken)
Expand All @@ -17,7 +17,7 @@ ecosystem into InfluxDB using Grafana for a frontend
Requirements:
* [Python 3.6.7+](https://www.python.org/downloads/release/python-367/)
* [Python3-pip](https://pip.pypa.io/en/stable/installing/)
* [InfluxDB 1.8.x](https://www.influxdata.com/)
* [InfluxDB 1.8.x or 2.0.x](https://www.influxdata.com/)
* [Grafana](https://grafana.com/)

<p align="center">
Expand Down Expand Up @@ -58,4 +58,4 @@ do not include database creation, please ensure you create an influx database
named `varken`

### Grafana
[Grafana Installation/Dashboard Documentation](https://wiki.cajun.pro/books/varken/page/grafana)
[Grafana Installation/Dashboard Documentation](https://wiki.cajun.pro/books/varken/page/grafana)
25 changes: 24 additions & 1 deletion Varken.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
# Needed to check version of python
from varken import structures # noqa
from varken.ombi import OmbiAPI
from varken.overseerr import OverseerrAPI
from varken.unifi import UniFiAPI
from varken import VERSION, BRANCH, BUILD_DATE
from varken.sonarr import SonarrAPI
from varken.radarr import RadarrAPI
from varken.lidarr import LidarrAPI
from varken.iniparser import INIParser
from varken.dbmanager import DBManager
from varken.influxdb2manager import InfluxDB2Manager
from varken.helpers import GeoIPHandler
from varken.tautulli import TautulliAPI
from varken.sickchill import SickChillAPI
Expand Down Expand Up @@ -90,7 +92,15 @@ def thread(job, **kwargs):
vl.logger.info("Varken v%s-%s %s", VERSION, BRANCH, BUILD_DATE)

CONFIG = INIParser(DATA_FOLDER)
DBMANAGER = DBManager(CONFIG.influx_server)

if CONFIG.influx2_enabled:
# Use INFLUX version 2
vl.logger.info('Using INFLUXDBv2')
DBMANAGER = InfluxDB2Manager(CONFIG.influx_server)
else:
vl.logger.info('Using INFLUXDB')
DBMANAGER = DBManager(CONFIG.influx_server)

QUEUE = Queue()

if CONFIG.sonarr_enabled:
Expand Down Expand Up @@ -156,6 +166,19 @@ def thread(job, **kwargs):
at_time = schedule.every(server.issue_status_run_seconds).seconds
at_time.do(thread, OMBI.get_issue_counts).tag("ombi-{}-get_issue_counts".format(server.id))

if CONFIG.overseerr_enabled:
for server in CONFIG.overseerr_servers:
OVERSEER = OverseerrAPI(server, DBMANAGER)
if server.get_request_total_counts:
at_time = schedule.every(server.request_total_run_seconds).seconds
at_time.do(thread, OVERSEER.get_total_requests).tag("overseerr-{}-get_total_requests".format(server.id))
if server.get_request_status_counts:
at_time = schedule.every(server.request_status_run_seconds).seconds
at_time.do(thread, OVERSEER.get_request_status_counts).tag("overseerr-{}-get_request_status_counts".format(server.id))
if server.get_latest_requests:
at_time = schedule.every(server.num_latest_requests_seconds).seconds
at_time.do(thread, OVERSEER.get_latest_requests).tag("overseerr-{}-get_latest_requests".format(server.id))

if CONFIG.sickchill_enabled:
for server in CONFIG.sickchill_servers:
SICKCHILL = SickChillAPI(server, DBMANAGER)
Expand Down
24 changes: 24 additions & 0 deletions data/varken.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ radarr_server_ids = 1,2
lidarr_server_ids = false
tautulli_server_ids = 1
ombi_server_ids = 1
overseerr_server_ids = 1
sickchill_server_ids = false
unifi_server_ids = false
maxmind_license_key = xxxxxxxxxxxxxxxx
influx2_enabled = false

[influxdb]
url = influxdb.domain.tld
Expand All @@ -16,6 +18,15 @@ verify_ssl = false
username = root
password = root

[influx2]
url = influxdb2.domain.tld
org = ORG
token = TOKEN
timeout = 10000
ssl = false
verify_ssl = false
bucket = varken

[tautulli-1]
url = tautulli.domain.tld:8181
fallback_ip = 1.1.1.1
Expand Down Expand Up @@ -95,6 +106,19 @@ request_total_run_seconds = 300
get_issue_status_counts = true
issue_status_run_seconds = 300

[overseerr-1]
url = overseerr.domain.tld
apikey = xxxxxxxxxxxxxxxx
ssl = false
verify_ssl = false
get_request_total_counts = true
request_total_run_seconds = 300
get_request_status_counts = true
request_status_run_seconds = 300
get_latest_requests = true
num_latest_requests_to_fetch = 10
num_latest_requests_seconds = 300

[sickchill-1]
url = sickchill.domain.tld:8081
apikey = xxxxxxxxxxxxxxxx
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ geoip2==2.9.0
influxdb==5.2.0
schedule==0.6.0
distro==1.4.0
urllib3==1.26.5
urllib3==1.26.7
influxdb-client==1.14.0
49 changes: 49 additions & 0 deletions varken/influxdb2manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from sys import exit
from logging import getLogger
import influxdb_client
from influxdb_client import InfluxDBClient
from influxdb_client.client.write_api import SYNCHRONOUS


class InfluxDB2Manager(object):
def __init__(self, server):
self.server = server
self.logger = getLogger()
if self.server.url == "influxdb2.domain.tld":
self.logger.critical("You have not configured your varken.ini. Please read Wiki page for configuration")
exit()

self.influx = InfluxDBClient(url=self.server.url, token=self.server.token, org=self.server.org,
timeout=self.server.timeout, verify_ssl=self.server.verify_ssl,
ssl_ca_cert=self.server.ssl)
self.influx_write_api = self.influx.write_api(write_options=SYNCHRONOUS)

# Create the bucket if needed

bucket_api = self.influx.buckets_api()

try:
bucket = bucket_api.find_bucket_by_name(self.server.bucket)

if bucket is None:
self.logger.info('Creating bucket %s', self.server.bucket)

org_api = influxdb_client.service.organizations_service.OrganizationsService(self.influx.api_client)
orgs = org_api.get_orgs()
for org in orgs.orgs:
if org.name == self.server.org:
my_org = org

self.influx.buckets_api().create_bucket(bucket_name=self.server.bucket, org_id=my_org.id)
except Exception as e:
self.logger.error('Failed creating new InfluxDB bucket! Error: %s', e)

def write_points(self, data):
d = data
self.logger.info('Writing Data to InfluxDBv2 %s', d)

try:
self.influx_write_api.write(bucket=self.server.bucket, record=d)
except Exception as e:
self.logger.error('Error writing data to influxdb2. Dropping this set of data. '
'Check your database! Error: %s', e)
95 changes: 78 additions & 17 deletions varken/iniparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@
from varken.varkenlogger import BlacklistFilter
from varken.structures import SickChillServer, UniFiServer
from varken.helpers import clean_sid_check, rfc1918_ip_check, boolcheck
from varken.structures import SonarrServer, RadarrServer, OmbiServer, TautulliServer, InfluxServer
<<<<<<< HEAD
from varken.structures import SonarrServer, RadarrServer, OmbiServer, OverseerrServer, TautulliServer, InfluxServer, Influx2Server
=======
from varken.structures import SonarrServer, RadarrServer, OmbiServer, OverseerrServer, TautulliServer, InfluxServer
>>>>>>> 07cc5946f37b14ab268c795fbdc5092988c10e97
Comment on lines +12 to +16

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge conflict



class INIParser(object):
def __init__(self, data_folder):
self.config = None
self.data_folder = data_folder
self.filtered_strings = None
self.services = ['sonarr', 'radarr', 'lidarr', 'ombi', 'tautulli', 'sickchill', 'unifi']
self.services = ['sonarr', 'radarr', 'lidarr', 'ombi', 'overseerr', 'tautulli', 'sickchill', 'unifi']

self.logger = getLogger()
self.influx_server = InfluxServer()
Expand Down Expand Up @@ -144,23 +148,47 @@ def parse_opts(self, read_file=False):
if read_file:
self.config = self.read_file('varken.ini')
self.config_blacklist()

# Parse InfluxDB options
try:
url = self.url_check(env.get('VRKN_INFLUXDB_URL', self.config.get('influxdb', 'url')),
include_port=False, section='influxdb')
port = int(env.get('VRKN_INFLUXDB_PORT', self.config.getint('influxdb', 'port')))
ssl = boolcheck(env.get('VRKN_INFLUXDB_SSL', self.config.get('influxdb', 'ssl')))
verify_ssl = boolcheck(env.get('VRKN_INFLUXDB_VERIFY_SSL', self.config.get('influxdb', 'verify_ssl')))

username = env.get('VRKN_INFLUXDB_USERNAME', self.config.get('influxdb', 'username'))
password = env.get('VRKN_INFLUXDB_PASSWORD', self.config.get('influxdb', 'password'))
except NoOptionError as e:
self.logger.error('Missing key in %s. Error: %s', "influxdb", e)
self.rectify_ini()
return
self.influx2_enabled = env.get('VRKN_GLOBAL_INFLUXDB2_ENABLED',
self.config.getboolean('global', 'influx2_enabled'))

if self.influx2_enabled:
# Use INFLUX version 2
try:
url = self.url_check(env.get('VRKN_INFLUXDB2_URL', self.config.get('influx2', 'url')),
section='influx2')
ssl = boolcheck(env.get('VRKN_INFLUXDB2_SSL', self.config.get('influx2', 'ssl')))
verify_ssl = boolcheck(env.get('VRKN_INFLUXDB2_VERIFY_SSL', self.config.get('influx2', 'verify_ssl')))

org = env.get('VRKN_INFLUXDB2_ORG', self.config.get('influx2', 'org'))
bucket = env.get('VRKN_INFLUXDB2_BUCKET', self.config.get('influx2', 'bucket'))
token = env.get('VRKN_INFLUXDB2_TOKEN', self.config.get('influx2', 'token'))
timeout = env.get('VRKN_INFLUXDB2_TIMEOUT', self.config.get('influx2', 'timeout'))
except NoOptionError as e:
self.logger.error('Missing key in %s. Error: %s', "influx2", e)
self.rectify_ini()
return

self.influx_server = Influx2Server(url=url, token=token, org=org, timeout=timeout, ssl=ssl,
verify_ssl=verify_ssl, bucket=bucket)
else:
try:
url = self.url_check(env.get('VRKN_INFLUXDB_URL', self.config.get('influxdb', 'url')),
include_port=False, section='influxdb')
port = int(env.get('VRKN_INFLUXDB_PORT', self.config.getint('influxdb', 'port')))
ssl = boolcheck(env.get('VRKN_INFLUXDB_SSL', self.config.get('influxdb', 'ssl')))
verify_ssl = boolcheck(env.get('VRKN_INFLUXDB_VERIFY_SSL', self.config.get('influxdb', 'verify_ssl')))

username = env.get('VRKN_INFLUXDB_USERNAME', self.config.get('influxdb', 'username'))
password = env.get('VRKN_INFLUXDB_PASSWORD', self.config.get('influxdb', 'password'))
except NoOptionError as e:
self.logger.error('Missing key in %s. Error: %s', "influxdb", e)
self.rectify_ini()
return

self.influx_server = InfluxServer(url=url, port=port, username=username, password=password, ssl=ssl,
verify_ssl=verify_ssl)
self.influx_server = InfluxServer(url=url, port=port, username=username, password=password, ssl=ssl,
verify_ssl=verify_ssl)

# Check for all enabled services
for service in self.services:
Expand Down Expand Up @@ -292,6 +320,39 @@ def parse_opts(self, read_file=False):
request_total_run_seconds=request_total_run_seconds,
issue_status_counts=issue_status_counts,
issue_status_run_seconds=issue_status_run_seconds)

if service == 'overseerr':
get_latest_requests = boolcheck(env.get(
f'VRKN_{envsection}_GET_LATEST_REQUESTS',
self.config.get(section, 'get_latest_requests')))
num_latest_requests_to_fetch = int(env.get(
f'VRKN_{envsection}_NUM_LATEST_REQUESTS',
self.config.getint(section, 'num_latest_requests_to_fetch')))
num_latest_requests_seconds = int(env.get(
f'VRKN_{envsection}_NUM_LATEST_REQUESTS_SECONDS',
self.config.getint(section, 'num_latest_requests_seconds')))
get_request_total_counts = boolcheck(env.get(
f'VRKN_{envsection}_GET_REQUEST_TOTAL_COUNTS',
self.config.get(section, 'get_request_total_counts')))
request_total_run_seconds = int(env.get(
f'VRKN_{envsection}_REQUEST_TOTAL_RUN_SECONDS',
self.config.getint(section, 'request_total_run_seconds')))
get_request_status_counts = boolcheck(env.get(
f'VRKN_{envsection}_GET_REQUEST_STATUS_COUNTS',
self.config.get(section, 'get_request_status_counts')))
request_status_run_seconds = int(env.get(
f'VRKN_{envsection}_REQUEST_STATUS_RUN_SECONDS',
self.config.getint(section, 'request_status_run_seconds')))


server = OverseerrServer(id=server_id, url=scheme + url, api_key=apikey, verify_ssl=verify_ssl,
get_latest_requests=get_latest_requests,
num_latest_requests_to_fetch=num_latest_requests_to_fetch,
num_latest_requests_seconds=num_latest_requests_seconds,
get_request_total_counts=get_request_total_counts,
request_total_run_seconds=request_total_run_seconds,
get_request_status_counts=get_request_status_counts,
request_status_run_seconds=request_status_run_seconds)

if service == 'sickchill':
get_missing = boolcheck(env.get(f'VRKN_{envsection}_GET_MISSING',
Expand Down
Loading