mirror of
https://github.com/meeb/tubesync.git
synced 2025-06-25 06:26:37 +00:00
Reset tubesync/sync/models.py (#16)
This commit is contained in:
parent
233d384e25
commit
2a63e3a360
@ -514,36 +514,11 @@ class Source(models.Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def type_directory_path(self):
|
def type_directory_path(self):
|
||||||
# Get the directory mode from the environment
|
|
||||||
directory_mode = os.getenv("TUBESYNC_DIRECTORY_MODE", "default")
|
|
||||||
|
|
||||||
# Default behavior
|
|
||||||
if directory_mode == "default":
|
|
||||||
if self.source_resolution == self.SOURCE_RESOLUTION_AUDIO:
|
if self.source_resolution == self.SOURCE_RESOLUTION_AUDIO:
|
||||||
return Path(settings.DOWNLOAD_AUDIO_DIR) / self.directory
|
return Path(settings.DOWNLOAD_AUDIO_DIR) / self.directory
|
||||||
else:
|
else:
|
||||||
return Path(settings.DOWNLOAD_VIDEO_DIR) / self.directory
|
return Path(settings.DOWNLOAD_VIDEO_DIR) / self.directory
|
||||||
|
|
||||||
# Flat mode - Place all files in the root
|
|
||||||
elif directory_mode == "flat":
|
|
||||||
return Path(settings.DOWNLOAD_DIR) / self.directory
|
|
||||||
|
|
||||||
# Custom mode - Parse prefixes for audio and video
|
|
||||||
elif directory_mode.startswith("custom:"):
|
|
||||||
try:
|
|
||||||
audio_prefix, video_prefix = directory_mode.split(":")[1].split(",")
|
|
||||||
except ValueError:
|
|
||||||
raise ValueError("Invalid format for TUBESYNC_DIRECTORY_MODE=custom. Expected 'custom:audio_prefix,video_prefix'.")
|
|
||||||
|
|
||||||
if self.source_resolution == self.SOURCE_RESOLUTION_AUDIO:
|
|
||||||
return Path(settings.DOWNLOAD_DIR) / audio_prefix / self.directory
|
|
||||||
else:
|
|
||||||
return Path(settings.DOWNLOAD_DIR) / video_prefix / self.directory
|
|
||||||
|
|
||||||
# Fallback for invalid modes
|
|
||||||
else:
|
|
||||||
raise ValueError(f"Unsupported TUBESYNC_DIRECTORY_MODE: {directory_mode}")
|
|
||||||
|
|
||||||
def make_directory(self):
|
def make_directory(self):
|
||||||
return os.makedirs(self.directory_path, exist_ok=True)
|
return os.makedirs(self.directory_path, exist_ok=True)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user