Esempio n. 1
0
        public string GetImdbIdByMovieHash(string movieFilename)
        {
            string _result = null;

            if (FileManager.DisableOpenSubtitles)
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(movieFilename) && File.Exists(movieFilename) && m_osdbProxy != null && m_Token != null)
            {
                subInfo[] subs = new subInfo[1];
                subs[0]               = new subInfo();
                subs[0].imdbid        = string.Empty;
                subs[0].sublanguageid = "";
                subs[0].moviehash     = GetMovieHash(movieFilename);
                subs[0].moviebytesize = new FileInfo(movieFilename).Length.ToString();
                subs[0].query         = string.Empty;

                subrt subrt = null;
                try
                {
                    subrt = m_osdbProxy.SearchSubtitles(m_Token, subs);
                }
                catch { }
                if (subrt != null && subrt.data.Length != 0)
                {
                    _result = "tt" + subrt.data[0].IDMovieImdb.PadLeft(7, '0');
                }
            }
            return(_result);
        }
Esempio n. 2
0
        private subrt DoSearch(string movieFilename, string sumCD, string language, string imdbid, string query, OSSearchType searchType)
        {
            subrt _result = null;

            if (!string.IsNullOrEmpty(movieFilename) && File.Exists(movieFilename) && m_osdbProxy != null && m_Token != null)
            {
                subInfo[] subs = new subInfo[1];
                subs[0] = new subInfo();
                subs[0].sublanguageid = language;

                switch (searchType)
                {
                case OSSearchType.MovieHashAndSize:
                    subs[0].moviehash     = GetMovieHash(movieFilename);
                    subs[0].moviebytesize = new FileInfo(movieFilename).Length.ToString();
                    subs[0].imdbid        = string.Empty;
                    subs[0].query         = string.Empty;
                    break;

                case OSSearchType.IMDbId:
                    subs[0].moviehash     = string.Empty;
                    subs[0].moviebytesize = string.Empty;
                    subs[0].imdbid        = string.IsNullOrEmpty(imdbid) ? string.Empty : imdbid;
                    subs[0].query         = string.Empty;
                    break;

                case OSSearchType.Query:
                    subs[0].moviehash     = string.Empty;
                    subs[0].moviebytesize = string.Empty;
                    subs[0].imdbid        = string.Empty;
                    subs[0].query         = string.IsNullOrEmpty(query) ? string.Empty : query;
                    break;

                default:
                    break;
                }

                try
                {
                    _result = m_osdbProxy.SearchSubtitles(m_Token, subs);
                }
                catch { }
            }

            return(_result);
        }