Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
toddrob99 committed Oct 18, 2020
1 parent 1f841b0 commit 2453106
Show file tree
Hide file tree
Showing 13 changed files with 1,297 additions and 1 deletion.
143 changes: 143 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
**/*sample*
**/*settings.py
**/.flake8
**/__pycache__
**/logs
**/data
**/local
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
logs/
*.db
*settings.py
local/

.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E203, E501, W503
exclude = .git,__pycache__,docs,build,dist,logs
max-line-length = 88
112 changes: 112 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
data/
local/
logs/
*.db
*settings.py

.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.9-alpine

LABEL Name=Searcharr Version=1.0.0

WORKDIR /app
ADD . /app

RUN apk add --no-cache --virtual .build-deps gcc musl-dev libffi-dev openssl-dev python3-dev

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install -r requirements.txt

CMD ["python3", "searcharr.py"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Todd
Copyright (c) 2020 Todd Roberts

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Searcharr
## Sonarr & Radarr Telegram Bot
### By Todd Roberts
https://github.com/toddrob99/searcharr

This bot allows users to add movies to Radarr and series to Sonarr via Telegram messaging app.

## Setup & Run

### Configure

Rename `settings-sample.py` to `settings.py`, and edit the settings within the file as necessary.

You are required to update the following settings, at minimum:

* Searcharr Bot > Password
* Telegram Bot > Token
* Sonarr > URL, API Key, Quality Profile ID
* Radarr > URL, API Key, Quality Profile ID

### Docker & Docker-Compose

Docker is the suggested method to run Searcharr. Be sure to map the following in your Docker container:

* Settings file to /app/settings.py
* Database folder to /app/data
* Log folder to /app/logs

A docker-compose.yml file is provided for your convenience. Update the volume mappings listed above, and then run `docker-compose up -d` to start Searcharr.

### Run from Source

If running from source, use Python 3.8.3+, install requirements using `python -m pip install -r requirements.txt`, and then run `searcharr.py`.

## Use

### Authenticate

Send a private message to your bot saying `/start <password>`.

**Caution**: This command will work in a group chat, but then everyone else in the group will see the password. If not all group members should be allowed to use the bot, then be sure to authenticate in a private message.

### Search & Add a Series to Sonarr

Send the bot a (private or group) message saying `/series <title>`. The bot will reply with information about the first result, along with buttons to move forward and back within the search results, pop out to tvdb or IMDb, add the current series to Sonarr, or cancel the search. When you click the button to add the series to Sonarr, the bot will ask what root folder to put the series in--unless you only have one root folder configured in Sonarr, in which case it will add it straight away.

### Search & Add a Movie to Radarr

Send the bot a (private or group) message saying `/movie <title>`. The bot will reply with information about the first result, along with buttons to move forward and back within the search results, pop out to IMDb, add the current movie to Radarr, or cancel the search. When you click the button to add the movie to Radarr, the bot will ask what root folder to put the movie in--unless you only have one root folder configured in Radarr, in which case it will add it straight away.
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3.0'
services:
searcharr:
container_name: searcharr
image: toddrob/searcharr:latest
volumes:
- ./data:/app/data
- ./logs:/app/logs
- ./settings.py:/app/settings.py
environment:
- TZ=America/New_York
restart: unless-stopped
network_mode: host
39 changes: 39 additions & 0 deletions log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Searcharr
Sonarr & Radarr Telegram Bot
Log Helper
By Todd Roberts
https://github.com/toddrob99/searcharr
"""
import logging
import os


def set_up_logger(logger_name, verbose, console):
if verbose:
rootLogger = logging.getLogger()
rootLogger.setLevel(logging.DEBUG)

logger = logging.getLogger(logger_name)
logger.setLevel(logging.DEBUG if verbose else logging.INFO)

formatter = logging.Formatter(
"%(asctime)s - %(levelname)8s - %(name)s(%(thread)s):%(lineno)d - %(message)s"
)

if console:
ch = logging.StreamHandler()
ch.setFormatter(formatter)
logger.addHandler(ch)

fileName = f"{logger_name}.log"
logPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "logs")
if not os.path.exists(logPath):
os.makedirs(logPath)
fh = logging.handlers.TimedRotatingFileHandler(
os.path.join(logPath, fileName), when="midnight", interval=1, backupCount=7
)
fh.setFormatter(formatter)
logger.addHandler(fh)

return logger
Loading

0 comments on commit 2453106

Please sign in to comment.