private VideoDetails FillVideoDetails(SingleVideo.RootObject core, VideoComments.RootObject comments, SingleChannel.RootObject channel)
        {
            if (core == null || core.items.Count <= 0)
            {
                return(null);
            }
            var C = core.items[0];

            var v = new VideoDetails();

            v.CommentCount = C.statistics.commentCount;
            v.Description  = C.snippet.description;

            if (comments != null && comments.items.Count > 0)
            {
                v.LastCommentDate =
                    DateTime.Parse(comments.items[0].snippet.topLevelComment.snippet.publishedAt);
            }


            v.Likes    = C.statistics.likeCount;
            v.Dislikes = C.statistics.dislikeCount;

            v.Title         = C.snippet.title;
            v.UploadedDate  = DateTime.Parse(C.snippet.publishedAt);
            v.VideoDuration = System.Xml.XmlConvert.ToTimeSpan(C.contentDetails.duration);
            v.VideoURL      = "https://youtube.com/watch?v=" + C.id;
            v.ViewCount     = C.statistics.viewCount;
            v.Subscribers   = channel.items.Count > 0 ? int.Parse(channel.items[0].statistics.subscriberCount) : 0;

            v.ChannelURL = "https://www.youtube.com/channel/" + C.snippet.channelId + "/";
            v.NumLinks   = Regex.Matches(v.Description, "http").Count;
            return(v);
        }
Ejemplo n.º 2
0
        private async Task ProcessYoutubeVideo(VideoDetails videoDetails, string mediaType, string quality)
        {
            if (videoDetails == null)
            {
                return;
            }

            await DownloadThumbnails(videoDetails);

            var path = mediaPath + $"\\{videoDetails.id}.{mediaType}";

            try
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                await clientHelper.DownloadMedia(videoDetails.id, quality, path, mediaType);

                var fileInfo = new FileInfo(path);
                RecordMetadata(videoDetails, mediaType, quality, fileInfo.Length);
            }
            catch (Exception ex)
            {
                // todo: handle error
            }

            UpdateLibraryStatistics();
            UpdateJobStatistics();
            isProcessingJob = false;
            ProcessJobFromQueue();
        }
Ejemplo n.º 3
0
        public void MediaPlayerAction(MetaData metaData, LaunchControl action)
        {
            VideoDetails videoOrPptDetails = VideoCollection.Find(x => x.Id == metaData.VideoId);

            if (videoOrPptDetails != null)
            {
                switch (action)
                {
                case LaunchControl.Launch:
                case LaunchControl.Play:
                    mediaPlayer.PlayVideo(videoOrPptDetails);
                    break;

                case LaunchControl.PlayAfterPause:
                    mediaPlayer.PlayAfterPauseVideo();
                    break;

                case LaunchControl.Pause:
                    mediaPlayer.PauseVideo();
                    break;

                case LaunchControl.Stop:
                    mediaPlayer.StopVideo();
                    break;
                }
            }
            else
            {
                MessageBox.Show("Media Not Found");
            }
        }
Ejemplo n.º 4
0
        public void TestMethod1()
        {
            Dictionary <string, List <VideoDetails> > mainIndex = new Dictionary <string, List <VideoDetails> >();
            string fileName = "Communication";
            Video  video    = Video.LoadVideoFromResource(fileName);

            video.Metadata = new VideoMetadata("Engineering", "Information Sys. Engineering", "Communication 101", "Dr. Gal Shpitz");
            List <string> keywords = new List <string>(video.GetMostFrequentStrings(5).Keys);
            VideoDetails  vd       = new VideoDetails(fileName, keywords);

            foreach (string term in video.Terms.Keys)
            {
                if (!mainIndex.ContainsKey(term))
                {
                    mainIndex[term] = new List <VideoDetails>();
                }
                mainIndex[term].Add(vd);
            }
            using (FileStream stream = File.Open("MainIndex.bin", FileMode.Create))
            {
                BinaryFormatter writer = new BinaryFormatter();
                writer.Serialize(stream, mainIndex);
            }

            using (FileStream stream = File.Open("CommunicationFull.bin", FileMode.Create))
            {
                BinaryFormatter writer = new BinaryFormatter();
                writer.Serialize(stream, video);
            }
        }
Ejemplo n.º 5
0
        public void UpdateVideo(VideoDetails videoDetails)
        {
            int    maxId = GetMaxId("tblVideos", "Id") + 1;
            string query = "INSERT INTO [tblVideos]([Id],[VideoHeader],[VideoUrl])VALUES(" + maxId + ",'" + videoDetails.VideoHeader + "','" + videoDetails.VideoUrl + "');";

            ExecuteNonQuery(query);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the IMDb video
        /// </summary>
        /// <param name="session">Session instance.</param>
        /// <param name="imdbID">IMDb ID</param>
        /// <returns></returns>
        public static VideoDetails GetVideo(Session session, string imdbID)
        {
            VideoDetails details = new VideoDetails();

            details.session = session;
            details.ID      = imdbID;

            string   url  = string.Format(session.Settings.VideoInfo, imdbID);
            string   data = session.MakeRequest(url);
            HtmlNode root = Utility.ToHtmlNode(data);

            if (root == null)
            {
                return(details);
            }

            HtmlNode titleNode = root.SelectSingleNode("//title");
            string   title     = titleNode.InnerText;

            title = title.Substring(title.IndexOf(':') + 1).Trim();

            details.Title = HttpUtility.HtmlDecode(title);

            Match tmp = VIdeoPropertiesExpression.Match(data);

            if (tmp.Success)
            {
                JObject contentData = JObject.Parse(tmp.Groups["json"].Value);
                var     vids        = contentData["videos"]["videoMetadata"][imdbID];
                details.Description = vids.Value <String>("description");
                foreach (var enc in vids["encodings"])
                {
                    var format = enc.Value <String>("definition");
                    var vidUrl = enc.Value <String>("videoUrl");
                    switch (format)
                    {
                    case "SD":
                        details.Files[VideoFormat.SD] = vidUrl;
                        break;

                    case "480p":
                        details.Files[VideoFormat.HD480] = vidUrl;
                        break;

                    case "720p":
                        details.Files[VideoFormat.HD720] = vidUrl;
                        break;
                    }
                    ;
                }
            }


            if (details.Files.Count == 0)
            {
                details.Files.Add(VideoFormat.SD, "/video/screenplay/" + imdbID + "/player");
            }

            return(details);
        }
Ejemplo n.º 7
0
        public async Task <ViewResult> View(Guid videoId)
        {
            // Get the views for the video and try to find the video by id (in parallel)
            Task <PlayStats>    videoViewsTask   = _stats.GetNumberOfPlays(videoId);
            Task <VideoDetails> videoDetailsTask = _videoCatalog.GetVideo(videoId);

            await Task.WhenAll(videoViewsTask, videoDetailsTask);

            VideoDetails videoDetails = videoDetailsTask.Result;

            if (videoDetails == null)
            {
                throw new ArgumentException(string.Format("Could not find a video with id {0}", videoId));
            }

            // TODO: Better way than client-side JOIN?
            UserProfileViewModel profile = await GetUserProfile(videoDetails.UserId);

            bool inProgress = videoDetails.LocationType == VideoLocationType.Upload && videoDetails.Location == null;

            // Found the video, display it
            return(View(new ViewVideoViewModel
            {
                VideoId = videoId,
                Title = videoDetails.Name,
                Description = videoDetails.Description,
                LocationType = videoDetails.LocationType,
                Location = videoDetails.Location,
                Tags = videoDetails.Tags,
                UploadDate = videoDetails.AddedDate,
                InProgress = inProgress,
                Author = profile,
                Views = videoViewsTask.Result.Views
            }));
        }
        private void OnBrowser(string videoId)
        {
            Porter.Entity.VideoDetails videoDetails = new Porter.Entity.VideoDetails();
            try
            {
                VideoInfo video;
                videoDetails = VideoDetails.FirstOrDefault(a => a.VideoID == videoId);

                IEnumerable <VideoInfo> videos = DownloadUrlResolver.GetDownloadUrls(videoDetails.Url);
                //Get url video
                if (videoDetails.SelectedVideoExtensionType == null)
                {
                    video = videos.FirstOrDefault(a => a.VideoType == VideoType.Mp4);
                }
                else
                {
                    video = videos.First(p => p.VideoExtension == videoDetails.SelectedVideoExtensionType.VideoExtension &&
                                         p.Resolution == videoDetails.SelectedVideoExtensionType.Resolution);
                }

                if (video != null && !string.IsNullOrWhiteSpace(video.DownloadUrl))
                {
                    System.Diagnostics.Process.Start(video.DownloadUrl);
                }
            }
            catch (YoutubeParseException ex)
            {
                sadyoutube(videoDetails.Url);
            }
            catch (Exception)
            { }
        }
        private void sadyoutube(string url)
        {
            var v = VideoDetails.FirstOrDefault(a => a.Url.ToLower() == url.ToLower());

            v.DownlaodStatus = DownlaodStatus.Failure;
            v.ImageUrl       = System.AppDomain.CurrentDomain.BaseDirectory + "Resources\\sadyoutube.jpg";
        }
Ejemplo n.º 10
0
        private void configGetSelectedVideosCommand()
        {
            CommandGetList = new RelayCommand(o =>
            {
                if (Closed != null)
                {
                    var list = VideoDetails.Where(a => a.IsActive);

                    //  VideoDetails = new ObservableCollection<VideoDetails>(list);

                    using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
                    {
                        System.Windows.Forms.DialogResult result = dialog.ShowDialog();

                        list.ToList().ForEach(a =>
                        {
                            a.VideoPath = dialog.SelectedPath + "\\";
                            if (VideoExtensionTypeCustome != null)
                            {
                                a.SelectedVideoExtensionType = VideoExtensionTypeCustome;
                            }

                            a.CaptionTracksEnabled = CaptionTracksEnabled;
                        });
                    }

                    Closed(new ObservableCollection <Porter.Entity.VideoDetails>(list));
                }
            }, o => true);
        }
        public async Task <JsonNetResult> GetLatestStatus(GetLatestStatusViewModel model)
        {
            EncodingJobProgress status = await _uploads.GetStatusForVideo(model.VideoId);

            // If there isn't a status (yet) just return queued with a timestamp from 30 seconds ago
            if (status == null || string.IsNullOrEmpty(status.CurrentState))
            {
                return(JsonSuccess(new LatestStatusViewModel {
                    Status = "Queued", StatusDate = DateTimeOffset.UtcNow.AddSeconds(-30)
                }));
            }

            // If the job is finished, see if the video catalog has a location for the video yet (i.e. knows about it)
            string currentState = status.CurrentState;

            if (currentState == "Finished")
            {
                VideoDetails videoDetails = await _videoCatalog.GetVideo(model.VideoId);

                if (videoDetails.Location != null)
                {
                    currentState = "Ready for Playback";
                }
            }

            return(JsonSuccess(new LatestStatusViewModel {
                StatusDate = status.StatusDate, Status = currentState
            }));
        }
Ejemplo n.º 12
0
        private void customeVideoExtensionType(bool custome)
        {
            ProgressExtensionType = 0;
            ProgressPercentage    = "0 %";

            VideoDetails.ToList().ForEach(a =>
            {
                a.VideoExtensionType         = new ObservableCollection <VideoExtensionType>();
                a.SelectedVideoExtensionType = null;


                if (custome)
                {
                    Task task = new Task(() =>
                    {
                        ObservableCollection <VideoExtensionType> listVideoExtension = new ObservableCollection <VideoExtensionType>();

                        listVideoExtension = Helper.CustomVideoInfo.getVideoExtensionType(a.Url, custome);
                        //Clear befor fill
                        System.Windows.Application.Current.Dispatcher.Invoke(() =>    // <--- HERE
                        {
                            listVideoExtension.ToList().ForEach(q =>
                            {
                                if (a.VideoExtensionType == null)
                                {
                                    a.VideoExtensionType = new ObservableCollection <VideoExtensionType>();
                                }
                                a.VideoExtensionType.Add(q);
                                a.IsCustome = custome;
                            });
                            //
                            if (a.VideoExtensionType != null && a.VideoExtensionType.Any())
                            {
                                a.SelectedVideoExtensionType = a.VideoExtensionType[0];
                            }
                            //
                            ProgressExtensionType++;
                            ProgressPercentage = VideoDetails.Count == 0 ? "0" : string.Concat(((ProgressExtensionType * 100) / VideoDetails.Count).ToString(), " %");

                            if (ProgressExtensionType == VideoDetails.Count)
                            {
                                ListVideoExtensionTypeCustom = DownloadModel.GetListVideoDetailsCustom(VideoDetails);
                            }
                        });
                    }, cts.Token);
                    //{
                    //    IsBackground = true
                    //};

                    task.Start();
                }
                else
                {
                    a.IsCustome = custome;
                    ListVideoExtensionTypeCustom = new ObservableCollection <VideoExtensionType>();
                    VideoExtensionTypeCustome    = null;
                }
            });
        }
 private void configStopAllCommand()
 {
     StopAllCommand = new RelayCommand(o =>
     {
         VideoDetails.Where(a => a.DownlaodStatus != DownlaodStatus.End).ToList()
         .ForEach(a => a.DownlaodStatus = DownlaodStatus.Cancel);
     }, o => true);
 }
Ejemplo n.º 14
0
 private async Task DownloadMediumThumbnail(VideoDetails videoDetails)
 {
     if (videoDetails == null)
     {
         return;
     }
     await DownloadImageAsync($"{videoDetails.id}-medium", new Uri(videoDetails.thumbnails.MediumResUrl));
 }
Ejemplo n.º 15
0
        void fillVideo(string videoId)
        {
            using (Porter.Model.FetchVideoURL cls = new Porter.Model.FetchVideoURL())
            {
                var video = cls.GetVideoDetail(videoId);

                VideoDetails.Add(video);
            }
        }
Ejemplo n.º 16
0
        private void SubscribedMessage(Speech.Speech spokenText)
        {
            switch (spokenText.TextSpoken)
            {
            case "Thank you Dodo":
                Speech.SpeechSynthezier speechSynthezier = new Speech.SpeechSynthezier();
                speechSynthezier.Speak("Your welcome and thanks to giving me this oppurtunity");
                VideoDetails videoDetails = VideoCollection.Find(x => x.Id == 13);
                System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); });
                break;
                //case "Pause the Video Dodo":
                //    System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                //        PauseVideo();
                //    });

                //    break;
                //case "Continue video Dodo":
                //    System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                //        PlayAfterPauseVideo();
                //    });

                //    break;
                //case "Start gaurdx presentation":
                //    System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                //        PptDetails details = PptCollection.Find(x => x.Id == 3);
                //        PptAction(details);
                //    });

                //    break;
                //case "Backward video":
                //    System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                //        PositionBackVideo();
                //    });

                //    break;
                //case "Previous Slide Dodo":
                //    System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                //        if (objPresSet != null)
                //        {
                //            if (objPresSet.Count > 0)
                //            {
                //                objPres.SlideShowWindow.View.Previous();
                //            }
                //        }
                //    });

                //    break;
                //case "Stop video":
                //    System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                //        StopVideo();
                //    });

                //    break;
            }
        }
Ejemplo n.º 17
0
 public void PlayVideo(VideoDetails videoDetails)
 {
     if (videoDetails != null)
     {
         videoDetailsMain = videoDetails;
         string videoPath = System.IO.Path.Combine(Mocker.debugPath, "Videos", videoDetails.Name);
         DodoMediaPlayer.Source = new Uri(videoPath);
         this.Show();
         DodoMediaPlayer.Play();
     }
 }
        private void Downloader_DownloadProgressChanged(object sender, ProgressEventArgs e)
        {
            //https://video.google.com/timedtext?lang=en&v=5MgBikgcWnY
            //https://r4---sn-jtcxgp5-g0ie.googlevideo.com/videoplayback?v=GwXnyf6N3sk&signature=7C1F9D7F42857DAD397EC93DE05FC9A28FAA84A2.513E68EDC99EBAD6EE2F46A01EFDCC7770AB5380&initcwndbps=177500&key=yt6&mime=video/mp4&c=WEB&expire=1519910404&ei=pKmXWu_uFsfi1gKH3qbQCQ&lmt=1507227283906759&dur=652.109&itag=18&clen=14976452&gir=yes&ratebypass=yes&sparams=clen,dur,ei,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&requiressl=yes&fvip=1&source=youtube&pl=24&id=o-AD56wpv4EjKfi_M-PoSffwhEYduVcqVRw5aVbst4ZSp0&mv=m&mt=1519888664&ms=au,rdu&mn=sn-jtcxgp5-g0ie,sn-5hne6nsy&mm=31,29&ip=212.119.82.100&ipbits=0

            Dispatcher.CurrentDispatcher.Invoke((Action) delegate // <--- HERE
            {
                var videoInfo = ((VideoDownloader)sender).Video;

                var video = VideoDetails.FirstOrDefault(a => a.Titel.ToLower() == videoInfo.Title.ToLower());
                if (video != null)
                {
                    //Command Stop Download
                    if (video.DownlaodStatus == DownlaodStatus.Cancel)
                    {
                        e.Cancel = true;
                        if (video.SelectedVideoExtensionType != null)
                        {
                            removeExistFile(video.VideoPath + video.Titel,
                                            video.SelectedVideoExtensionType.VideoExtension);
                        }
                    }

                    if (video.SelectedVideoExtensionType == null)
                    {
                        var listVideoExtensionType = Helper.CustomVideoInfo.getVideoExtensionType(video.Url, false);
                        if (listVideoExtensionType != null && listVideoExtensionType.Count != 0)
                        {
                            video.SelectedVideoExtensionType = listVideoExtensionType[0];
                        }
                    }

                    if (video != null)
                    {
                        video.ProgressPercentage = double.Parse($"{string.Format("{0:0.##}", e.ProgressPercentage)}");
                        //ProgressValue
                        var listProgressPercentage = VideoDetails
                                                     .Where(a => a.DownlaodStatus == DownlaodStatus.Begin &&
                                                            a.IsActive == true
                                                            ) //&& a.EndDownload == false
                                                     .ToList().Select(a => a.ProgressPercentage).ToList();

                        if (listProgressPercentage.Any())
                        {
                            ProgressValue = double.Parse($"{string.Format("{0:0.##}", listProgressPercentage.Average())}") * .01;
                        }
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
            });
        }
Ejemplo n.º 19
0
 public string UpdateVideo(VideoDetails videoDetails)
 {
     try
     {
         Business business = new Business();
         return(business.UpdateVideo(videoDetails));
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Ejemplo n.º 20
0
        private void UpdateStatusImage(VideoDetails videoDetails)
        {
            if (videoDetails == null)
            {
                imgStatus.Source = null;
                return;
            }

            var uri = new Uri($"{mediaPath}\\{videoDetails.id}-medium.jpg", UriKind.Absolute);

            imgStatus.Source = new BitmapImage(uri);
        }
Ejemplo n.º 21
0
        protected async override void OnAppearing()
        {
            base.OnAppearing();
            // This is because we don't want to load the data again and again.
            if (string.IsNullOrEmpty(episodeTitle.Text))
            {
                VideoDetails showDetails = new VideoDetails(this._showId, this._episodeId);
                this.singleEpisode = await showDetails.getAllContent();

                episodeTitle.Text = this.singleEpisode.episodeTitle;
            }
        }
Ejemplo n.º 22
0
        private void powerpnt_SlideShowEnd(powerpointinterop.Presentation Wn)
        {
            Wn.Close();
            VideoDetails videoDetails = null;

            switch (pptDetailsMain.Id)
            {
            case 1:
                //azad exit and rpa video start
                videoDetails = VideoCollection.Find(x => x.Id == 2);
                System.Windows.Application.Current.Dispatcher.InvokeAsync(() => { PlayVideo(videoDetails); });
                break;

            case 2:
                //rpa video
                videoDetails = VideoCollection.Find(x => x.Id == 3);
                System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                    PlayVideo(videoDetails);
                });
                break;

            case 3:
                //market data entry bot
                videoDetails = VideoCollection.Find(x => x.Id == 6);
                System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                    PlayVideo(videoDetails);
                });
                break;

            case 4:
                //market data ppt end
                videoDetails = VideoCollection.Find(x => x.Id == 7);
                System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                    PlayVideo(videoDetails);
                });
                break;

            case 5:
                //market data ends and
                //tech video start
                videoDetails = VideoCollection.Find(x => x.Id == 10);
                System.Windows.Application.Current.Dispatcher.InvokeAsync(() => {
                    PlayVideo(videoDetails);
                });
                break;

            case 6:
                speechRecognize.StartListening();
                subscription = EventAggregator.getInstance().Subscribe <Speech.Speech>(SubscribedMessage);
                break;
            }
        }
        private void configStopCommand()
        {
            StopCommand = new RelayCommand(o =>
            {
                var videoSelected = ((Porter.Entity.VideoDetails)o);

                var video = VideoDetails.FirstOrDefault(a => a.Titel == videoSelected.Titel);
                if (video != null)
                {
                    video.DownlaodStatus = DownlaodStatus.Cancel;
                }
            }, o => checkDownloadStatusIsCompleted(o, DownlaodStatus.Begin));
        }
 private void configRemoveAllCommand()
 {
     RemoveAllCommand = new RelayCommand(o =>
     {
         if (Loging.RemoveAll())
         {
             for (int i = VideoDetails.Count - 1; i >= 0; i--)
             {
                 VideoDetails.RemoveAt(i);
             }
         }
     }, o => true);
 }
Ejemplo n.º 25
0
        private async Task DownloadThumbnails(VideoDetails videoDetails)
        {
            if (videoDetails == null)
            {
                return;
            }
            await DownloadImageAsync($"{videoDetails.id}-low", new Uri(videoDetails.thumbnails.LowResUrl));

            //await DownloadImageAsync($"{videoDetails.id}-medium", new Uri(videoDetails.thumbnails.MediumResUrl));
            await DownloadImageAsync($"{videoDetails.id}-standard", new Uri(videoDetails.thumbnails.StandardResUrl));
            await DownloadImageAsync($"{videoDetails.id}-high", new Uri(videoDetails.thumbnails.HighResUrl));
            await DownloadImageAsync($"{videoDetails.id}-max", new Uri(videoDetails.thumbnails.MaxResUrl));
        }
        public bool DownloadSubtitel(VideoDetails videoDetails, List <CaptionTracks> listCaptionTracks)
        {
            string url = "";

            if (listCaptionTracks == null || listCaptionTracks.Count == 0)
            {
                return(false);
            }
            else
            {
                url = listCaptionTracks[0].baseUrl;
            }
            TimedText timeText = getTimedText(url, videoDetails.Titel);

            if (timeText != null)
            {
                FileStream file = new FileStream(videoDetails.VideoPath + Helper.RemoveSpatialCharacter(videoDetails.Titel) + ".srt",
                                                 FileMode.Create,
                                                 FileAccess.Write);


                StringBuilder builder = new StringBuilder();
                for (int i = 0; i < timeText.events.Count; i++)
                {
                    var _event = timeText.events[i];

                    builder.AppendLine((i + 1).ToString());

                    builder
                    .Append(Helper.MilliSeconds(_event.tStartMs))
                    .Append(" --> ")
                    .AppendLine(Helper.MilliSeconds(_event.tStartMs + _event.dDurationMs));

                    if (_event.segs != null && _event.segs.Count != 0)
                    {
                        builder.AppendLine(_event.segs[0].utf8);
                    }
                    builder.AppendLine();
                }

                UnicodeEncoding uniencoding = new UnicodeEncoding();
                byte[]          result      = uniencoding.GetBytes(builder.ToString());

                file.Write(result, 0, result.Length);
                //---------

                file.Close();
                file.Dispose();
            }
            return(true);
        }
Ejemplo n.º 27
0
        //Open the selected file with the corresponding program
        private void Row_DoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                FileDetails  fl = FileList.SelectedItem as FileDetails;
                ImageDetails Il = FileList.SelectedItem as ImageDetails;
                WordDetails  Wl = FileList.SelectedItem as WordDetails;
                PDFdetails   Pl = FileList.SelectedItem as PDFdetails;
                VideoDetails Vl = FileList.SelectedItem as VideoDetails;
                AudioDetails Al = FileList.SelectedItem as AudioDetails;
                OtherDetails Ol = FileList.SelectedItem as OtherDetails;
                try
                {
                    if (fl != null)
                    {
                        System.Diagnostics.Process.Start(fl.path.ToString());
                    }
                    if (Il != null)
                    {
                        System.Diagnostics.Process.Start(Il.Path.ToString());
                    }

                    if (Wl != null)
                    {
                        System.Diagnostics.Process.Start(Wl.path.ToString());
                    }

                    if (Pl != null)
                    {
                        System.Diagnostics.Process.Start(Wl.path.ToString());
                    }
                    if (Vl != null)
                    {
                        System.Diagnostics.Process.Start(Vl.path.ToString());
                    }
                    if (Al != null)
                    {
                        System.Diagnostics.Process.Start(Al.path.ToString());
                    }
                    if (Ol != null)
                    {
                        System.Diagnostics.Process.Start(Ol.path.ToString());
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("Imposible d'ouvir le fichier" + ex.Message);
                }
            }
        }
        //private void OnFetchVideo(string s)
        //{
        //    if (Porter.Model.Helper.UrlIsValid(FullUrl))
        //    {

        //        var childWindow = new PorterTube.ChildWindowView.ChildWindowView();
        //        childWindow.Closed += (list =>
        //        {

        //            customDownloadResolver(list);
        //            if (list.Count > 0)
        //            {

        //                App.Current.Dispatcher.Invoke((Action)(() =>
        //                {
        //                    for (int i = VideoDetails.Count - 1; i >= 0; i--)
        //                    {
        //                        var videoID = VideoDetails[i].VideoID;
        //                        bool any = list.ToList().Any(l => l.VideoID == videoID);
        //                        if (any)
        //                            VideoDetails.RemoveAt(i);
        //                    }

        //                    list.ToList().ForEach(a =>
        //                    VideoDetails.Add(a));
        //                }
        //                ));
        //            }
        //        });
        //        childWindow.Show(FullUrl);
        //    }
        //    else
        //    {
        //        System.Windows.Forms.MessageBox.Show("Invalid URL");
        //    }
        //}

        private void customDownloadResolver(ObservableCollection <VideoDetails> list)
        {
            try
            {
                list.ToList().ForEach(a =>
                {
                    var select                   = a.SelectedVideoExtensionType;
                    a.VideoExtensionType         = null;
                    a.SelectedVideoExtensionType = select;
                    VideoDetails.Add(a);
                });
            }
            catch (Exception)
            { }
        }
Ejemplo n.º 29
0
        public static void AddMediaMetadata(VideoDetails videoDetails, string mediaType, string quality, long size)
        {
            var newEntity = new MediaMetadata()
            {
                YID       = videoDetails.id,
                Title     = videoDetails.Title,
                DateStamp = DateTime.UtcNow,
                ThumbUrl  = videoDetails.thumbnails.MediumResUrl,
                MediaType = mediaType,
                Quality   = quality,
                Size      = size
            };

            DBContext.Current.Save(newEntity);
        }
        public static void TestDownloadSubtitelAsync()
        {
            var v = new VideoDetails();

            v.Titel     = "Difference between LOOK, WATCH & SEE - Learn English Grammar";
            v.VideoPath = "C:\\Users\\aola\\Desktop\\Download\\";
            v.VideoID   = "JkURo4oTKNk";
            //JkURo4oTKNk
            for (int i = 0; i < 10; i++)
            {
                using (FetchSubtitelURL sub = new FetchSubtitelURL())
                {
                    //sub.DownloadSubtitel(v,);
                }
            }
        }