public void ViewOnTMDB(FilmographyType.Value type, int tmdbId) { if (tmdbId == 0) { return; } string language = "en-US"; string url = new ViewURL_TMDB_Builder().PrepareURL(type, tmdbId); Console.WriteLine("url: " + url); SystemUtils.OpenUrl(url); }
/// <summary> /// Gets files by filmography type and index. /// </summary> /// <param name="fileNames"></param> /// <param name="type"></param> /// <param name="index"></param> /// <returns></returns> private static List <string> GetFilesByIndex(List <string> filePaths, FilmographyType.Value type, int index) { if (filePaths == null) { return(null); } List <string> results = new List <string>(); // runs check for every file in list foreach (string filePath in filePaths) { // checks if file matches index if (FileNameMatchesIndex(Path.GetFileName(filePath), index, type)) { switch (type) { case FilmographyType.Value.SEASON: // adds file to results if it is a directory (season directory is always a directory) if (GetFileType(filePath) == FILE_TYPE.DIRECTORY) { results.Add(filePath); } break; case FilmographyType.Value.EPISODE: // deep search for episodes // -> if we are searching for episodes, and file is a directory, // searches for elements inside directory if (GetFileType(filePath) == FILE_TYPE.DIRECTORY) { results.AddRange(GetFilesByIndex( Directory.GetFiles(filePath).ToList(), FilmographyType.Value.EPISODE, index)); } else { results.Add(filePath); } break; } } } return(results); }
public string PrepareURL(FilmographyType.Value type, Dictionary <KEY, object> parameters) { switch (type) { case FilmographyType.Value.MOVIE: // TODO throw new NotImplementedException(); case FilmographyType.Value.SERIES: AppendPath(KEY.TV); AppendPath((int)parameters[KEY.TMDB_ID]); break; case FilmographyType.Value.SEASON: AppendPath(KEY.TV); AppendPath((int)parameters[KEY.TMDB_ID]); AppendPath(KEY.SEASON); AppendPath((int)parameters[KEY.SEASON_NUMBER]); break; case FilmographyType.Value.EPISODE: AppendPath(KEY.TV); AppendPath((int)parameters[KEY.TMDB_ID]); AppendPath(KEY.SEASON); AppendPath((int)parameters[KEY.SEASON_NUMBER]); AppendPath(KEY.EPISODE); AppendPath((int)parameters[KEY.EPISODE_NUMBER]); break; } parameters.Remove(KEY.TMDB_ID); parameters.Remove(KEY.SEASON_NUMBER); parameters.Remove(KEY.EPISODE_NUMBER); ParameterList <string> appendToResponse = new ParameterList <string>(); appendToResponse.Add(KEY_Strings[KEY.EXTERNAL_IDS]); parameters.Add(KEY.APPEND_TO_RESPONSE, appendToResponse); AppendParams(parameters); return(ToString()); }
public string PrepareURL(FilmographyType.Value type, int tmdbId) { switch (type) { case FilmographyType.Value.MOVIE: AppendPath(KEY.MOVIE); break; case FilmographyType.Value.SERIES: AppendPath(KEY.TV); break; default: // TODO throw new NotImplementedException(); } AppendPath(tmdbId); return(ToString()); }
public string PrepareURL(FilmographyType.Value type, Dictionary <KEY, object> parameters) { AppendPath(KEY.SEARCH); switch (type) { case FilmographyType.Value.MOVIE: throw new NotSupportedException(); case FilmographyType.Value.SERIES: case FilmographyType.Value.SEASON: case FilmographyType.Value.EPISODE: // TODO AppendPath(KEY.TV); break; } AppendParams(parameters); return(ToString()); }
/** * Checks if file name matches given index (EPISODE or SEASON). * @param file Subject of check * @param index EPISODE or SEASON index to check * @param type EPISODE or SEASON * @return true if file name matches index */ private static bool FileNameMatchesIndex(string fileName, int index, FilmographyType.Value type) { if (fileName == null || index < 0) { return(false); } List <Regex> patterns = new List <Regex>(); switch (type) { case FilmographyType.Value.SEASON: /* Regexp explanation: * [Ss](eason)? - character 's' (can be either capital or not) * or string 'season' (first 's' can be either capital or not) * \s* - 0 or more white-spaces * followed by the season index * (\D+\d*)? - not followed by a digit */ patterns.Add(new Regex(".*[Ss](eason)?\\s*0?" + index + "(\\D+\\d*)?")); break; case FilmographyType.Value.EPISODE: /* Regexp explanation: * [Ee](pisode)? - character 'e' (can be either capital or not) * or string 'episode' (first 'e' can be either capital or not) * \s* - 0 or more white-spaces * followed by the episode index * \D - followed by a non-digit */ patterns.Add(new Regex(".*[Ee](pisode)?\\s*0?" + index + "\\D")); /* Regexp explanation: * [Ee](pisode)? - character 'e' (can be either capital or not) * or string 'episode' (first 'e' can be either capital or not) * \s* - 0 or more white-spaces * followed by the episode index * $ - end of string */ patterns.Add(new Regex(".*[Ee](pisode)?\\s*0?" + index + "$")); /* Regexp explanation: * X or x * followed by 0 or 1 zeros * followed by the episode index * followed by a non-digit */ patterns.Add(new Regex(".*[Xx]0?" + index + "\\D+")); /* Regexp explanation: * X or x * followed by 0 or 1 zeros * followed by the episode index * $ - end of string */ patterns.Add(new Regex(".*[Xx]0?" + index + "$")); break; default: throw new ArgumentException(); } foreach (Regex regex in patterns) { Match match = regex.Match(fileName); if (match.Success) { return(true); } } return(false); }