Esempio n. 1
0
        /// <summary>
        /// The main function, in wich we call the api with the options that we got from the form.
        /// </summary>
        /// <param name="searchMode">If it's to search by title or by ID.</param>
        /// <param name="q">Word(s) that we search.</param>
        /// <param name="m">If it's to search movies or tv series.</param>
        /// <param name="nAct">Number of actors to parse in each title.</param>
        /// <param name="sS">Number of the first season we want to parse.</param>
        /// <param name="eS">Number of the last season we want to parse.</param>
        /// <param name="f">Fields that we want to parse in each title.</param>
        public void IMDbSearch(int searchMode, string q, int m, int nAct, int sS, int eS, bool[] f)
        {
            this.query   = q;
            this.media   = m;
            this.nActors = nAct;
            this.sSeas   = sS;
            this.eSeas   = eS;
            this.fields  = f;
            string url  = "";
            int    type = -1;

            if (searchMode == 0)
            {
                url += "http://www.imdb.com/find?s=all&q=" + query;
            }
            else if (searchMode == 1)
            {
                url += "http://www.imdb.com/title/" + query;
            }

            IMDB imdb = new IMDB();

            imdb.parentErrorCaller    = errorCaller;
            imdb.parentProgressCaller = progressCaller;

            bool success = imdb.getPage(url);

            if (success && searchMode == 0 && !error)
            {
                type = imdb.getPageType(media, query);
            }
            if (type == 0 && !error)
            {
                List <IMDbLink> links = imdb.parseTitleLinks(media); // Gets the relevant links from that page
                if (links.Count > 0)
                {
                    processInfo(1, links);
                    progressHandler(20);
                }
                else
                {
                    errorHandler(new Exception("No results found!"));
                }
            }
            else if (!error)
            {
                progressHandler(20);
                IMDbTitle title = imdb.parseTitlePage(fields, media, nActors, sSeas, eSeas);
                processInfo(0, title);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Parses a page of a title
 /// </summary>
 /// <param name="url">Relative URL of the page to be parsed</param>
 public void IMDbParse(string url)
 {
     if (!error)
     {
         IMDB imdb = new IMDB();
         imdb.parentErrorCaller    = errorCaller;
         imdb.parentProgressCaller = progressCaller;
         bool ok = imdb.getPage("http://www.imdb.com" + url);
         if (ok && !error)
         {
             IMDbTitle title = imdb.parseTitlePage(fields, media, nActors, sSeas, eSeas);
             processInfo(0, title);
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// The main function, in wich we call the api with the options that we got from the form.
        /// </summary>
        /// <param name="searchMode">If it's to search by title or by ID.</param>
        /// <param name="q">Word(s) that we search.</param>
        /// <param name="m">If it's to search movies or tv series.</param>
        /// <param name="nAct">Number of actors to parse in each title.</param>
        /// <param name="sS">Number of the first season we want to parse.</param>
        /// <param name="eS">Number of the last season we want to parse.</param>
        /// <param name="f">Fields that we want to parse in each title.</param>
        public void IMDbSearch(int searchMode, string q, int m, int nAct, int sS, int eS, bool[] f)
        {
            this.query = q;
            this.media = m;
            this.nActors = nAct;
            this.sSeas = sS;
            this.eSeas = eS;
            this.fields = f;
            string url = "";
            int type = -1;
            if (searchMode == 0)
            {
                url += "http://www.imdb.com/find?s=all&q=" + query;
            }
            else if (searchMode == 1)
            {
                url += "http://www.imdb.com/title/" + query;
            }

            IMDB imdb = new IMDB();
            imdb.parentErrorCaller = errorCaller;
            imdb.parentProgressCaller = progressCaller;

            bool success = imdb.getPage(url);

            if (success && searchMode == 0 && !error)
            {
                type = imdb.getPageType(media, query);
            }
            if (type == 0 && !error)
            {
                List<IMDbLink> links = imdb.parseTitleLinks(media); // Gets the relevant links from that page
                if (links.Count > 0)
                {
                    processInfo(1, links);
                    progressHandler(20);
                }
                else
                {
                    errorHandler(new Exception("No results found!"));
                }
            }
            else if(!error)
            {
                progressHandler(20);
                IMDbTitle title = imdb.parseTitlePage(fields, media, nActors, sSeas, eSeas);
                processInfo(0, title);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Parses a page of a title
 /// </summary>
 /// <param name="url">Relative URL of the page to be parsed</param>
 public void IMDbParse(string url)
 {
     if (!error)
     {
         IMDB imdb = new IMDB();
         imdb.parentErrorCaller = errorCaller;
         imdb.parentProgressCaller = progressCaller;
         bool ok = imdb.getPage("http://www.imdb.com" + url);
         if (ok && !error)
         {
             IMDbTitle title = imdb.parseTitlePage(fields, media, nActors, sSeas, eSeas);
             processInfo(0, title);
         }
     }
 }