Exemplo n.º 1
0
        private static List <SearchSubtitleResult> DoSearchRequest(XmlRpcStruct ResponseStruct)
        {
            List <SearchSubtitleResult> SearchResultList = new List <SearchSubtitleResult>();

            if (ResponseStruct["data"] != null && (!ResponseStruct["data"].Equals(false)))
            {
                foreach (XmlRpcStruct SearchResult in ((object[])ResponseStruct["data"]))
                {
                    SearchSubtitleResult result = new SearchSubtitleResult();
                    result.SubSumCD           = (string)SearchResult["SubSumCD"];
                    result.MovieYear          = (String)SearchResult["MovieYear"];
                    result.SubFileName        = (String)SearchResult["SubFileName"];
                    result.MovieImdbRating    = (String)SearchResult["MovieImdbRating"];
                    result.UserNickName       = (String)SearchResult["UserNickName"];
                    result.UserRank           = (String)SearchResult["UserRank"];
                    result.SubHash            = (String)SearchResult["SubHash"];
                    result.MovieName          = (String)SearchResult["MovieName"];
                    result.SubActualCD        = (String)SearchResult["SubActualCD"];
                    result.MovieNameEng       = (String)SearchResult["MovieNameEng"];
                    result.SubHearingImpaired = (String)SearchResult["SubHearingImpaired"];
                    result.MatchedBy          = (String)SearchResult["MatchedBy"];
                    result.MovieHash          = (String)SearchResult["MovieHash"];
                    result.LanguageName       = (String)SearchResult["LanguageName"];
                    result.IDSubtitleFile     = (String)SearchResult["IDSubtitleFile"];
                    result.SubLanguageID      = (String)SearchResult["SubLanguageID"];
                    result.SubAuthorComment   = (String)SearchResult["SubAuthorComment"];
                    result.IDSubtitle         = (String)SearchResult["IDSubtitle"];
                    result.UserID             = (String)SearchResult["UserID"];
                    result.MovieByteSize      = (String)SearchResult["MovieByteSize"];
                    result.SubSize            = (String)SearchResult["SubSize"];
                    result.SubDownloadLink    = (String)SearchResult["SubDownloadLink"];
                    result.SubtitlesLink      = (String)SearchResult["SubtitlesLink"];
                    result.ISO639             = (String)SearchResult["ISO639"];
                    result.MovieReleaseName   = (String)SearchResult["MovieReleaseName"];
                    result.SubBad             = (String)SearchResult["SubBad"];
                    result.IDSubMovieFile     = (String)SearchResult["IDSubMovieFile"];
                    result.SubComments        = (String)SearchResult["SubComments"];
                    result.MovieTimeMS        = (String)SearchResult["MovieTimeMS"];
                    result.SubFormat          = (String)SearchResult["SubFormat"];
                    result.IDMovieImdb        = (String)SearchResult["IDMovieImdb"];
                    result.SubRating          = (String)SearchResult["SubRating"];
                    result.MovieFPS           = (string)SearchResult["MovieFPS"];
                    try
                    {
                        result.SubDownloadsCnt = Convert.ToInt32((String)SearchResult["SubDownloadsCnt"]);
                    }
                    catch (Exception)
                    {
                        result.SubDownloadsCnt = 0;
                    }
                    result.IDMovie         = (String)SearchResult["IDMovie"];
                    result.SubAddDate      = (String)SearchResult["SubAddDate"];
                    result.ZipDownloadLink = (String)SearchResult["ZipDownloadLink"];
                    SearchResultList.Add(result);
                }
            }
            return(SearchResultList);
        }
Exemplo n.º 2
0
 private static List<SearchSubtitleResult> DoSearchRequest(XmlRpcStruct ResponseStruct)
 {
     List<SearchSubtitleResult> SearchResultList = new List<SearchSubtitleResult>();
     if (ResponseStruct["data"] != null && (!ResponseStruct["data"].Equals(false)))
     {
         foreach (XmlRpcStruct SearchResult in ((object[])ResponseStruct["data"]))
         {
             SearchSubtitleResult result = new SearchSubtitleResult();
             result.SubSumCD = (string)SearchResult["SubSumCD"];
             result.MovieYear = (String)SearchResult["MovieYear"];
             result.SubFileName = (String)SearchResult["SubFileName"];
             result.MovieImdbRating = (String)SearchResult["MovieImdbRating"];
             result.UserNickName = (String)SearchResult["UserNickName"];
             result.UserRank = (String)SearchResult["UserRank"];
             result.SubHash = (String)SearchResult["SubHash"];
             result.MovieName = (String)SearchResult["MovieName"];
             result.SubActualCD = (String)SearchResult["SubActualCD"];
             result.MovieNameEng = (String)SearchResult["MovieNameEng"];
             result.SubHearingImpaired = (String)SearchResult["SubHearingImpaired"];
             result.MatchedBy = (String)SearchResult["MatchedBy"];
             result.MovieHash = (String)SearchResult["MovieHash"];
             result.LanguageName = (String)SearchResult["LanguageName"];
             result.IDSubtitleFile = (String)SearchResult["IDSubtitleFile"];
             result.SubLanguageID = (String)SearchResult["SubLanguageID"];
             result.SubAuthorComment = (String)SearchResult["SubAuthorComment"];
             result.IDSubtitle = (String)SearchResult["IDSubtitle"];
             result.UserID = (String)SearchResult["UserID"];
             result.MovieByteSize = (String)SearchResult["MovieByteSize"];
             result.SubSize = (String)SearchResult["SubSize"];
             result.SubDownloadLink = (String)SearchResult["SubDownloadLink"];
             result.SubtitlesLink = (String)SearchResult["SubtitlesLink"];
             result.ISO639 = (String)SearchResult["ISO639"];
             result.MovieReleaseName = (String)SearchResult["MovieReleaseName"];
             result.SubBad = (String)SearchResult["SubBad"];
             result.IDSubMovieFile = (String)SearchResult["IDSubMovieFile"];
             result.SubComments = (String)SearchResult["SubComments"];
             result.MovieTimeMS = (String)SearchResult["MovieTimeMS"];
             result.SubFormat = (String)SearchResult["SubFormat"];
             result.IDMovieImdb = (String)SearchResult["IDMovieImdb"];
             result.SubRating = (String)SearchResult["SubRating"];
             try
             {
                 result.SubDownloadsCnt = Convert.ToInt32((String)SearchResult["SubDownloadsCnt"]);
             }
             catch (Exception)
             {
                 result.SubDownloadsCnt = 0;
             }
             result.IDMovie = (String)SearchResult["IDMovie"];
             result.SubAddDate = (String)SearchResult["SubAddDate"];
             result.ZipDownloadLink = (String)SearchResult["ZipDownloadLink"];
             SearchResultList.Add(result);
         }
     }
     return SearchResultList;
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public MemoryStream DownloadSubtitle(SearchSubtitleResult SearchResult)
        {
            XmlRpcStruct ResponseStruct = proxy.DownloadSubtitles(Token, new int[1] {
                Convert.ToInt32(SearchResult.IDSubtitleFile)
            });

            byte[] encodedDataAsBytes = System.Convert.FromBase64String((String)((XmlRpcStruct)((object[])ResponseStruct["data"])[0])["data"]);
            using (MemoryStream ms = new MemoryStream(encodedDataAsBytes))
            {
                int    msgLength = BitConverter.ToInt32(encodedDataAsBytes, 0);
                byte[] buffer    = new byte[msgLength];

                ms.Position = 0;
                using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
                {
                    zip.Read(buffer, 0, buffer.Length);
                    return(new MemoryStream(buffer));
                }
            }
        }
Exemplo n.º 4
0
 private string getSubtitleText(SearchSubtitleResult item, out string state)
 { 
     string subtitle;
     try
     {
         MemoryStream st = session.DownloadSubtitle(item);
         subtitle = Encoding.Default.GetString(st.ToArray());
         string path = Application.StartupPath + "\\Movies\\" + item.IDMovieImdb + "\\" + item.LanguageName + "\\";
         Directory.CreateDirectory(path);
         File.WriteAllText(path + item.SubFileName, subtitle);
         state = "ok";
         Console.WriteLine(item.IDMovieImdb + " " + item.LanguageName + " " + item.SubFileName + " downloaded");
     }
     catch (Exception)
     {
         Console.WriteLine(item.IDMovieImdb + " subtitle download error!");
         state = "Error";
         return "";
     }
     return subtitle;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public MemoryStream DownloadSubtitle(SearchSubtitleResult SearchResult)
        {
            XmlRpcStruct ResponseStruct = proxy.DownloadSubtitles(Token, new int[1] { Convert.ToInt32(SearchResult.IDSubtitleFile) });
            byte[] encodedDataAsBytes = System.Convert.FromBase64String((String)((XmlRpcStruct)((object[])ResponseStruct["data"])[0])["data"]);
            using (MemoryStream ms = new MemoryStream(encodedDataAsBytes))
            {
                int msgLength = BitConverter.ToInt32(encodedDataAsBytes, 0);
                byte[] buffer = new byte[msgLength];

                ms.Position = 0;
                using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
                { 
                    zip.Read(buffer, 0, buffer.Length);
                    return new MemoryStream(buffer);
                }
            }
        }