Beispiel #1
0
        public bool AddVideo(VideoInstance Video)
        {
            if (GetVideoByID(Video.ID) == null)
            {
                Videos.Add(Video);
                Save();
                return true;
            }

            return false;
        }
Beispiel #2
0
 void Video_DownloadStateChanged(VideoInstance Video, DownloadProgressChangedEventArgs e)
 {
     lock (Video)
     {
         if (e != null)
         {
             const float MB = 1024.0f * 1024.0f;
             TimeSpan ElapsedTime = DateTime.Now - DownloadStartTime;
             float DownloadRate = (float)((e.BytesReceived / MB) / ElapsedTime.TotalSeconds);
             Console.CursorLeft = 0;
             Console.Write("Progress: {0}% {1:f2}/{2:f2}MB {3:f2}M/s", Video.DownloadStatus, e.BytesReceived / MB, e.TotalBytesToReceive / MB, DownloadRate);
             Console.CursorLeft = 0; // next write will overwrite this line
         }
     }
 }
Beispiel #3
0
 void GetVideosOfType(string VideoTypeName)
 {
     int VideoType = -1;
     if (Client.VideoTypes.TryGetValue(VideoTypeName, out VideoType))
     {
         Logger.LogVerbose("Fetching {0} latest {1} videos", Properties.Settings.Default.QueryBatchSize, VideoTypeName);
         VideoInfo[] Infos = Client.GetLatestVideos(Properties.Settings.Default.QueryBatchSize, VideoType);
         if (Infos != null)
         {
             foreach (VideoInfo Info in Infos)
             {
                 VideoInstance Video = new VideoInstance(Info);
                 Video.DownloadDirectory = Path.Combine(Properties.Settings.Default.DownloadDirectory, VideoTypeName);
                 if (DB.AddVideo(Video))
                 {
                     Logger.LogVerbose("Found {0}:{1}", Video.Title, Video.RemoteFilename);
                 }
             }
         }
         Logger.LogVerbose("Done");
     }
     else
     {
         Logger.Log("Bad video type requested: {0}", VideoTypeName);
     }
 }
Beispiel #4
0
 void DownloadVideo(VideoInstance Video)
 {
     Logger.Log("Downloading {0}:{1}", Video.Title, Video.RemoteFilename);
     Video.DownloadStateChanged += new VideoInstance.DownloadStateChangedHandler(Video_DownloadStateChanged);
     DownloadStartTime = DateTime.Now;
     Video.Download();
     DB.Save();
     Logger.Log("Download complete");
 }