Shoko.Server/API/v3/Controllers/FileController.cs
/// <summary>
/// Search for a file by path or name. Internally, it will convert / to the system directory separator and match against the string
/// </summary>
/// <param name="path">a path to search for. URL Encoded</param>
/// <returns></returns>
Search for a file by path or name. Internally, it will convert / to the system directory separator and match against the string
Search for a file by path or name . Internally it will convert / to the system directory separator and match against the string
[HttpGet("PathEndsWith/{*path}")]
        public ActionResult<List<File.FileDetailed>> SearchByFilename(string path)
        {
            var query = path;
            if (query.Contains("%") || query.Contains("+")) query = Uri.UnescapeDataString(query);
            if (query.Contains("%")) query = Uri.UnescapeDataString(query);
            query = query.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar);
            var results = RepoFactory.VideoLocalPlace.GetAll().AsParallel()
                .Where(a => a.FullServerPath.EndsWith(query, StringComparison.OrdinalIgnoreCase)).Select(a => a.VideoLocal)
                .Distinct()
                .Where(a =>
                {
                    var ser = a?.GetAnimeEpisodes().FirstOrDefault()?.GetAnimeSeries();
                    return ser == null || User.AllowedSeries(ser);
                }).Select(a => new File.FileDetailed(HttpContext, a)).ToList();
            return results;
        }
[ HttpGet ( " " ) ] public ActionResult < List < File . FileDetailed > > SearchByFilename ( string path ) { var query = path ; if ( query . Contains ( " " ) || query . Contains ( " " ) ) query = Uri . UnescapeDataString ( query ) ; if ( query . Contains ( " " ) ) query = Uri . UnescapeDataString ( query ) ; query = query . Replace ( ' ' , Path . DirectorySeparatorChar ) . Replace ( ' \\ ' , Path . DirectorySeparatorChar ) ; var results = RepoFactory . VideoLocalPlace . GetAll ( ) . AsParallel ( ) . Where ( a => a . FullServerPath . EndsWith ( query , StringComparison . OrdinalIgnoreCase ) ) . Select ( a => a . VideoLocal ) . Distinct ( ) . Where ( a => { var ser = a ? . GetAnimeEpisodes ( ) . FirstOrDefault ( ) ? . GetAnimeSeries ( ) ; return ser == null || User . AllowedSeries ( ser ) ; } ) . Select ( a => new File . FileDetailed ( HttpContext , a ) ) . ToList ( ) ; return results ; }
Search for a file by path or name.
Search for a file by path or name .
None
path
string
a path to search for. URL Encoded
a path to search for . URL Encoded