コード例 #1
0
ファイル: DownloadMgmtUtils.cs プロジェクト: jmn319/mmb
        //Updated December 23rd - Sleep 1 min
        public static void DownloadTorrentFiles()
        {
            List <BasicShow> showsToDownload  = TvUtils.GetEpisodesToDownload();
            List <Movie>     moviesToDownload = MovieUtils.GetMoviesToDownload();

            TvUtils.SetShowDownloadLocations(showsToDownload);
            DownloadShows(showsToDownload);
            DownloadMovies(moviesToDownload);
            Thread.Sleep(60000);
        }
コード例 #2
0
ファイル: DownloadMgmtUtils.cs プロジェクト: jmn319/mmb
        //Updated July 5th
        public static void MonitorAndMove()
        {
            try
            {
                List <Pending> pendingList = MongoUtils.GetMongoCollection
                                             (
                    @"mongodb://" + ConfigurationManager.AppSettings["mongoHost"] + @"/",
                    ConfigurationManager.AppSettings["port"],
                    ConfigurationManager.AppSettings["db"],
                    ConfigurationManager.AppSettings["pending_collection"]
                                             ).FindAllAs <Pending>().ToList <Pending>();

                //Get the names of the files in the downloaded folder to compare against those pending
                List <string> tempS = Directory.GetFiles(ConfigurationManager.AppSettings["file_download_path"]).ToList();
                tempS.AddRange(Directory.GetDirectories(ConfigurationManager.AppSettings["file_download_path"]).ToList());

                foreach (var p in pendingList)
                {
                    foreach (var str in tempS.Where(str => str.Equals(ConfigurationManager.AppSettings["file_download_path"] + @"\" + p.FileName)))
                    {
                        if (p.Movie)
                        {
                            MoveFile(str.Replace(@"\\", @"\"), str.Replace(@"\\", @"\").Replace(ConfigurationManager.AppSettings["file_download_path"],
                                                                                                ConfigurationManager.AppSettings["movie_move_path"]));
                            MovieUtils.SetToDownloaded(p.Name);
                            MovieUtils.MoveToDownloaded(p.Name);
                        }
                        else if (p.Show)
                        {
                            MoveFile(str.Replace(@"\\", @"\"), str.Replace(@"\\", @"\").Replace(ConfigurationManager.AppSettings["file_download_path"],
                                                                                                ConfigurationManager.AppSettings["show_move_path"]));
                            TvUtils.SetToDownloaded(p.Name, p.Season, p.Episode);
                            TvUtils.MoveToDownloaded(p.Name, p.Season, p.Episode);
                            TvUtils.UpdateCheckMyShow(p.Name, p.Season, p.Episode);
                        }
                    }
                }
            }
            catch (Exception e)
            { Log.AppendToLog("Error : FATAL monitor and move. " + e, ConfigurationManager.AppSettings["log_file"]); }
        }
コード例 #3
0
ファイル: DownloadMgmtUtils.cs プロジェクト: jmn319/mmb
        //Updated July 24th - TODO: Need to accept download quality from user in config
        public static void DownloadMovies(List <Movie> moviesToDownload)
        {
            try
            {
                MongoCollection pendingCollection = MongoUtils.GetMongoCollection
                                                    (
                    @"mongodb://" + ConfigurationManager.AppSettings["mongoHost"] + @"/",
                    ConfigurationManager.AppSettings["port"],
                    ConfigurationManager.AppSettings["db"],
                    ConfigurationManager.AppSettings["pending_collection"]
                                                    );

                foreach (var m in moviesToDownload.Where(s => !MovieUtils.IsInPending(s) && !MovieUtils.IsInDownloaded(s)))
                {
                    var torURL = "";
                    //Is the preferred download quality avilable?
                    foreach (var t in m.DownloadLogistics)
                    {
                        if (t.Quality == ConfigurationManager.AppSettings["yts_quality_pref"])
                        {
                            torURL = t.TorrentUrl;
                        }
                    }
                    //Preferred quality was not available. Get next.
                    if (torURL == "")
                    {
                        foreach (var t in m.DownloadLogistics)
                        {
                            if (t.Quality != ConfigurationManager.AppSettings["yts_quality_excl"])
                            {
                                torURL = t.TorrentUrl;
                            }
                        }
                    }

                    //Download torrent file to temp folder first to be able to extract the video filename
                    DownloadFile(torURL,
                                 ConfigurationManager.AppSettings["temp_torrent_download_path"] + @"\" + ((m.ImdbTitle == null) ? m.YtsMovieTitle : m.ImdbTitle) + ".torrent");
                    //Pull video filename out of the torrent file
                    string        name         = MovieUtils.NameFromDownloadString(((m.ImdbTitle == null) ? m.YtsMovieTitle : m.ImdbTitle));
                    List <string> fileNameArry = name.Split(':').ToList();
                    foreach (var f in fileNameArry.Where(f => f.Contains("name")))
                    {
                        name = fileNameArry[fileNameArry.IndexOf(f) + 1];
                        name = name.Substring(0, name.Length - 2);
                        break;
                    }

                    pendingCollection.Insert(new Pending()
                    {
                        FileName = name,
                        Name     = m.YtsMovieTitle,
                        Show     = false,
                        Movie    = true
                    });
                    //Move the torrent file from temp into downloads
                    MoveFile(ConfigurationManager.AppSettings["temp_torrent_download_path"] + @"\" + m.YtsMovieTitle + ".torrent",
                             ConfigurationManager.AppSettings["torrent_download_path"] + @"\" + m.YtsMovieTitle + ".torrent");
                    break;
                }
            }
            catch (Exception e)
            { Log.AppendToLog("Error : FATAL download movie. " + e, ConfigurationManager.AppSettings["log_file"]); }
        }
コード例 #4
0
ファイル: RestServices.cs プロジェクト: jmn319/mmb
 public object Post(ModifyInfoRequest request)
 {
     //Handle null objects on the client side code
     if (request.Show)
     {
         if (request.ModType == "delete")
         {
             Console.WriteLine("Delete show post: " + DateTime.Now.ToString("M/d/yyyy H:mm:ss:ff"));
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response", Value = TvUtils.RemoveShowFromMyShow(request.Name)
             }));
         }
         else if (request.ModType == "add")
         {
             Console.WriteLine("Add show post: " + DateTime.Now.ToString("M/d/yyyy H:mm:ss:ff"));
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response",
                 Value = TvUtils.AddShowToMyShows(request.Name, request.Season, request.Episode)
             }));
         }
         else if (request.ModType == "modify")
         {
             Console.WriteLine("Modify show post: " + DateTime.Now.ToString("M/d/yyyy H:mm:ss:ff"));
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response",
                 Value = TvUtils.UpdateMyShow(request.Name, request.Season, request.Episode)
             }));
         }
         else
         {
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response", Value = "I don't understand your request"
             }));
         }
     }
     else
     {
         if (request.ModType == "delete")
         {
             Console.WriteLine("Delete movie post: " + DateTime.Now.ToString("M/d/yyyy H:mm:ss:ff"));
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response", Value = MovieUtils.RemoveMovieFromMyMovies(request.Name)
             }));
         }
         else if (request.ModType == "add")
         {
             Console.WriteLine("Add movie post: " + DateTime.Now.ToString("M/d/yyyy H:mm:ss:ff"));
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response",
                 Value = MovieUtils.AddMovieToMyMovies(request.Name, request.ImdbCode, request.Year)
             }));
         }
         else if (request.ModType == "modify")
         //TODO: build this out... or not? is it needed?
         {
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response", Value = "I don't understand your request... yet"
             }));
         }
         else
         {
             return(JsonSerializer.SerializeToString(new ReturnClass()
             {
                 Key = "response", Value = "I don't understand your request"
             }));
         }
     }
 }