/// <summary>
        /// Constructs a new metadata search form window and copies the specified search query into a new SearchQuery object.
        /// </summary>
        /// <param name="searchQuery"></param>
        public FormMetadataSearch(SearchQuery searchQuery)
        {
            InitializeComponent();

            SearchQuery.CopyFrom(searchQuery);

            textBoxSearchQuery.Text = searchQuery.Title;
            textBoxSearchQuery.TextChanged += TextBoxSearchQueryOnTextChanged;

            textBoxYear.Text = searchQuery.Year.HasValue ? searchQuery.Year.ToString() : "";
            textBoxYear.TextChanged += TextBoxYearOnTextChanged;

            Load += OnLoad;
            Resize += OnResize;
        }
Beispiel #2
0
 public void CopyFrom(SearchQuery other)
 {
     Title = other.Title;
     Year = other.Year;
     Language = other.Language;
 }
Beispiel #3
0
 protected bool Equals(SearchQuery other)
 {
     return string.Equals(Title, other.Title) && Year == other.Year && Equals(Language, other.Language);
 }
Beispiel #4
0
 private void QueryTmdb(int attempt, Job job, SearchQuery query)
 {
     MakeProgress(string.Format("Querying TMDb w/ year = {0} (attempt {1})...", query.Year, attempt));
     ApiRequest(job, query);
 }
Beispiel #5
0
        private void ApiRequest(Job job, SearchQuery query)
        {
            job.Movies.Clear();

            var searchTitle = query.Title;
            var searchYear = query.Year;

            if (_apiKey == null)
            {
                const string message = "ERROR: No API key found";
                Logger.Error(message);
                throw new Exception(message);
            }

            _tmdbApi = new Tmdb(_apiKey, _searchISO_639_1);

            // TMDb (previously) choked on dashes - not sure if it still does or not...
            // E.G.: "The Amazing Spider-Man" --> "The Amazing Spider Man"
            searchTitle = Regex.Replace(searchTitle, @"-+", " ");

            var requestParameters = new TmdbApiParameters(searchTitle, searchYear, _searchISO_639_1);

            try
            {
                SearchTmdb(requestParameters, job);
            }
            catch (Exception ex)
            {
                HandleTmdbError(ex);
            }
        }
Beispiel #6
0
        private static IList<SearchQuery> ConstructQueries(SearchQuery query)
        {
            var queries = new List<SearchQuery>();

            queries.Add(query);

            if (!query.Year.HasValue)
            {
                return queries;
            }

            // isan.org has the wrong year for some movies...
            // Search again w/ year + 1 if there are zero results for isan.org's year value
            queries.Add(new SearchQuery
                        {
                            Language = query.Language,
                            Title = query.Title,
                            Year = query.Year + 1
                        });

            // Search again w/o sending a year if there are still zero results
            queries.Add(new SearchQuery
                        {
                            Language = query.Language,
                            Title = query.Title,
                            Year = null
                        });

            return queries;
        }