File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -825,6 +825,36 @@ protected static function isDirectoryOnlyContainsNfo(string $directory): bool
825825 }
826826 }
827827
828+ /**
829+ * Convert a .strm file path to its corresponding .nfo path.
830+ *
831+ * Rules:
832+ * - If a path ends with a slash or is a directory, return "<dir>/tvshow.nfo".
833+ * - If a file path ends with ".strm" (case-insensitive), replace it with ".nfo".
834+ * - If the path already ends with ".nfo", return it unchanged.
835+ * - Otherwise append ".nfo" to the path.
836+ */
837+ protected static function strmPathToNfoPath (string $ path ): string
838+ {
839+ // Directory path -> tvshow.nfo
840+ if (str_ends_with ($ path , '/ ' ) || is_dir ($ path )) {
841+ return rtrim ($ path , '/ ' ).'/ ' .self ::TVSHOW_NFO_FILENAME ;
842+ }
843+
844+ // Already .nfo -> return as-is
845+ if (preg_match ('/\.nfo$/i ' , $ path )) {
846+ return $ path ;
847+ }
848+
849+ // Replace .strm with .nfo (case-insensitive)
850+ if (preg_match ('/\.strm$/i ' , $ path )) {
851+ return preg_replace ('/\.strm$/i ' , self ::NFO_EXTENSION , $ path );
852+ }
853+
854+ // Fallback: append .nfo
855+ return $ path .self ::NFO_EXTENSION ;
856+ }
857+
828858 /**
829859 * Clean up all orphaned files for all sync locations
830860 */
You can’t perform that action at this time.
0 commit comments