Skip to content

A self-hosted media server and file management system

feat: support language slugs in subtitle file names

aminnausinf84638e9cc9f
diff --git a/app/Models/Subtitle.php b/app/Models/Subtitle.php
index 75d26fd9..1fa9bb70 100644
--- a/app/Models/Subtitle.php
+++ b/app/Models/Subtitle.php
@@ -28,8 +28,8 @@ class Subtitle extends Model {
return SubtitlePath::directory($this->metadata_uuid);
}
- public function getFilePath(string $format): string {
- return SubtitlePath::file($this->metadata_uuid, $this->track_id, $format);
+ public function getFilePath(string $format, ?string $language = null): string {
+ return SubtitlePath::file($this->metadata_uuid, $this->track_id, $format, $language);
}
public static function getVisibleFields(): array {
diff --git a/app/Services/Subtitles/SubtitlePath.php b/app/Services/Subtitles/SubtitlePath.php
index 4991a6a9..acfd2812 100644
--- a/app/Services/Subtitles/SubtitlePath.php
+++ b/app/Services/Subtitles/SubtitlePath.php
@@ -11,7 +11,9 @@ class SubtitlePath {
return self::BASE_PATH . "/{$shard}/{$metadataUuid}/subtitles";
}
- public static function file(string $metadataUuid, int $trackId, string $format): string {
- return self::directory($metadataUuid) . "/{$trackId}.{$format}";
+ public static function file(string $metadataUuid, int $trackId, string $format, ?string $language = null): string {
+ $languageSlug = $language ? ".{$language}" : '';
+
+ return self::directory($metadataUuid) . "/{$trackId}{$languageSlug}.{$format}";
}
}