-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from dantebarba/bugfix/fix-library-subdir-scanning
+ If no subdir is present it scans the whole directory + New tests added + Refactored the name processor to allow different directory naming conventions + library search is mandatory since section.all() takes up to 20x times the section search + Added new movie and show processor module + Added new env var DIRECTORY_PROC_MODULE + Added new processing functions to module + Added new custom module as example + Dockerfile: included new module + Black run over all .py files + .gitignore updated with test .env + new processor_test added + README.md updated with new processor variable and description closes #6 fixes #5
- Loading branch information
Showing
10 changed files
with
170 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,7 +102,7 @@ celerybeat.pid | |
*.sage.py | ||
|
||
# Environments | ||
.env | ||
*.env | ||
.venv | ||
env/ | ||
venv/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""this is just an example for a custom name processor""" | ||
|
||
|
||
def preprocess_movie_directory(name: str): | ||
"""process movie directory by replacing all dots and underscores with spaces | ||
Args: | ||
name (str): movie directory path | ||
""" | ||
name = name.replace(".", " ").replace("_", " ") | ||
parts = name.split(" ") | ||
date_maybe = parts[-1] | ||
if date_maybe.startswith("(") and date_maybe.endswith(")"): | ||
return name.replace(date_maybe, "").rstrip() | ||
|
||
|
||
def preprocess_show_directory(name: str): | ||
"""this function receives a directory and returns the show name to be searched | ||
If you have radarr/sonarr file naming configured as default, leave it as is.""" | ||
parts = name.split(" ") | ||
date_maybe = parts[-1] | ||
if date_maybe.startswith("(") and date_maybe.endswith(")"): | ||
return name.replace(date_maybe, "").rstrip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def preprocess_movie_directory(name: str): | ||
"""this function receives a directory and returns the movie name to be searched | ||
If you have radarr/sonarr file naming configured as default, leave it as is.""" | ||
parts = name.split(" ") | ||
date_maybe = parts[-1] | ||
if date_maybe.startswith("(") and date_maybe.endswith(")"): | ||
return name.replace(date_maybe, "").rstrip() | ||
|
||
|
||
def preprocess_show_directory(name: str): | ||
"""this function receives a directory and returns the show name to be searched | ||
If you have radarr/sonarr file naming configured as default, leave it as is.""" | ||
parts = name.split(" ") | ||
date_maybe = parts[-1] | ||
if date_maybe.startswith("(") and date_maybe.endswith(")"): | ||
return name.replace(date_maybe, "").rstrip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import json | ||
import os | ||
import unittest | ||
|
||
from dotenv import load_dotenv | ||
|
||
from app import create_app | ||
|
||
|
||
class ProcessorTest(unittest.TestCase): | ||
def setUp(self): | ||
load_dotenv() | ||
load_dotenv(".processortest.env") | ||
self.app = create_app() | ||
self.client = self.app.test_client() | ||
self.base_url = "http://127.0.0.1" | ||
|
||
def test_custom_moviename_processor(self): | ||
media_directory = os.getenv("TEST_DIRECTORY_SUBDIR", "/test/testdir") | ||
response = self.client.post( | ||
"/triggers/manual", | ||
query_string={"dir": [media_directory]}, | ||
base_url=self.base_url, | ||
content_type="application/json", | ||
) | ||
|
||
self.assertEquals(response.status_code, 200) | ||
|
||
print(json.loads(response.data)) |