mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:43:28 +02:00
format files
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
@@ -5,7 +6,7 @@ from sqlalchemy.exc import IntegrityError
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from media_manager.config import MediaManagerConfig
|
||||
from media_manager.exceptions import InvalidConfigError
|
||||
from media_manager.exceptions import InvalidConfigError, NotFoundError
|
||||
from media_manager.indexer.repository import IndexerRepository
|
||||
from media_manager.database import SessionLocal, get_session
|
||||
from media_manager.indexer.schemas import IndexerQueryResult
|
||||
@@ -37,6 +38,7 @@ from media_manager.torrent.utils import (
|
||||
remove_special_characters,
|
||||
get_importable_media_directories,
|
||||
remove_special_chars_and_parentheses,
|
||||
extract_external_id_from_string,
|
||||
)
|
||||
from media_manager.indexer.service import IndexerService
|
||||
from media_manager.metadataProvider.abstractMetaDataProvider import (
|
||||
@@ -145,7 +147,9 @@ class MovieService:
|
||||
shutil.rmtree(movie_dir)
|
||||
log.info(f"Deleted movie directory: {movie_dir}")
|
||||
except OSError as e:
|
||||
log.error(f"Deleting movie directory: {movie_dir} : {e.strerror}")
|
||||
log.error(
|
||||
f"Deleting movie directory: {movie_dir} : {e.strerror}"
|
||||
)
|
||||
|
||||
if delete_torrents:
|
||||
# Get all torrents associated with this movie
|
||||
@@ -177,9 +181,7 @@ class MovieService:
|
||||
public_movie_files = [PublicMovieFile.model_validate(x) for x in movie_files]
|
||||
result = []
|
||||
for movie_file in public_movie_files:
|
||||
movie_file.imported = self.movie_file_exists_on_file(
|
||||
movie_file=movie_file
|
||||
)
|
||||
movie_file.imported = self.movie_file_exists_on_file(movie_file=movie_file)
|
||||
result.append(movie_file)
|
||||
return result
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class TransmissionDownloadClient(AbstractDownloadClient):
|
||||
"""
|
||||
torrent_hash = get_torrent_hash(torrent=indexer_result)
|
||||
download_dir = (
|
||||
MediaManagerConfig().misc.torrent_directory / indexer_result.title
|
||||
MediaManagerConfig().misc.torrent_directory / indexer_result.title
|
||||
)
|
||||
try:
|
||||
self._client.add_torrent(
|
||||
|
||||
@@ -128,7 +128,7 @@ def get_torrent_hash(torrent: IndexerQueryResult) -> str:
|
||||
:return: The hash of the torrent.
|
||||
"""
|
||||
torrent_filepath = (
|
||||
MediaManagerConfig().misc.torrent_directory / f"{torrent.title}.torrent"
|
||||
MediaManagerConfig().misc.torrent_directory / f"{torrent.title}.torrent"
|
||||
)
|
||||
if torrent_filepath.exists():
|
||||
log.warning(f"Torrent file already exists at: {torrent_filepath}")
|
||||
|
||||
Reference in New Issue
Block a user