/// <summary> /// Play file /// </summary> /// <param name="valueUrl"></param> /// <param name="title"></param> /// <param name="position"></param> private void play(string valueUrl, string title, int position, bool isVideo) { try { var tube = string.Empty; if (valueUrl.Contains("youtube")) { tube = "YouTube"; } else if (valueUrl.Contains("ccmixter")) { tube = "ccMixter"; } else if (valueUrl.Contains("dailymotion")) { tube = "Dailymotion"; } else if (valueUrl.Contains("eroprofile")) { tube = "Eroprofile"; } else if (valueUrl.Contains("pornhub")) { tube = "Pornhub"; } else if (valueUrl.Contains("vimeo")) { tube = "Vimeo"; } else if (valueUrl.Contains("xhamster")) { tube = "xHamster"; } var mediaUrl = string.Empty; switch (tube) { case "YouTube": IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(valueUrl, false); VideoInfo video = null; if (isVideo) { video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.AudioBitrate == 96); // mp4 video if (String.IsNullOrEmpty(video.DownloadUrl)) // Fallback { video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.AudioBitrate == 96 && info.Resolution == 240); // mp4 video } } else { video = videoInfos .First(info => info.VideoType == VideoType.Mobile); // 3gp } if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } mediaUrl = video.DownloadUrl; break; case "ccMixter": mediaUrl = ccMixterExtractor.DownloadUrl(valueUrl); break; case "Dailymotion": mediaUrl = DailymotionExtractor.DownloadUrl(valueUrl); break; case "Eroprofile": mediaUrl = EroprofileExtractor.DownloadUrl(valueUrl); break; case "Pornhub": var phitems = PornhubExtractor.Query(valueUrl); foreach (var item in phitems) { if (!String.IsNullOrEmpty(item.getUrl())) { mediaUrl = item.getUrl(); } } break; case "Vimeo": mediaUrl = VimeoExtractor.DownloadUrl(valueUrl); break; case "xHamster": var xhitmes = xHamsterExtractor.Query(valueUrl); foreach (var item in xhitmes) { if (!String.IsNullOrEmpty(item.getUrl())) { mediaUrl = item.getUrl(); } } break; default: return; } #if DEBUG Console.WriteLine("Media url: " + mediaUrl); #endif Log.println("Media url: " + mediaUrl); if (String.IsNullOrEmpty(mediaUrl)) { #if DEBUG Console.WriteLine("File not found", title); #endif Log.println("File not found: " + title); searchActivity_.publishnotification("File not found", title, searchActivity_.uniquenotificationID()); } else { if (isVideo) { var intent = new Intent(ActivityContext.mActivity, typeof(VideoPlayerActivity)); intent.PutExtra("url", mediaUrl); intent.PutExtra("title", title); ActivityContext.mActivity.StartActivity(intent); } else { mediaplayer(mediaUrl, position); } } } catch (Exception ex) { #if DEBUG Console.WriteLine(ex.ToString()); #endif Toast.MakeText(ActivityContext.mActivity, "Parsing error", ToastLength.Long).Show(); Log.println(ex.ToString()); } }
/// <summary> /// Download /// </summary> /// <param name="title"></param> /// <param name="url"></param> public void Download(string title, string url, bool isVideo) { // TITLE string mediaTitle = title; // URL string mediaUrl = null; // File extension string file_extension = string.Empty; try { switch (spinnerSelected) { case "YouTube": IEnumerable <VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(url, false); VideoInfo video = null; if (isVideo) { video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.AudioBitrate == 96); // mp4 video if (String.IsNullOrEmpty(video.DownloadUrl)) // Fallback { video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.AudioBitrate == 96 && info.Resolution == 240); // mp4 video } file_extension = ".mp4"; } else { video = videoInfos .First(info => info.VideoType == VideoType.Mp4 && info.AudioBitrate == 128); // m4a audio } if (video.RequiresDecryption) { DownloadUrlResolver.DecryptDownloadUrl(video); } mediaUrl = video.DownloadUrl; break; case "ccMixter": mediaUrl = ccMixterExtractor.DownloadUrl(url); break; case "Dailymotion": mediaUrl = DailymotionExtractor.DownloadUrl(url); file_extension = ".mp4"; break; case "Eroprofile": mediaUrl = EroprofileExtractor.DownloadUrl(url); file_extension = ".m4u"; break; case "Pornhub": var phitems = PornhubExtractor.Query(url); foreach (var item in phitems) { if (!String.IsNullOrEmpty(item.getUrl())) { mediaUrl = item.getUrl(); } } file_extension = ".mp4"; break; case "Vimeo": mediaUrl = VimeoExtractor.DownloadUrl(url); file_extension = ".mp4"; break; case "xHamster": var xhitmes = xHamsterExtractor.Query(url); foreach (var item in xhitmes) { if (!String.IsNullOrEmpty(item.getUrl())) { mediaUrl = item.getUrl(); } } file_extension = ".mp4"; break; default: return; } } catch { #if DEBUG Console.WriteLine("File not found", title); #endif Log.println("File not found: " + title); publishnotification("File not found", title, uniquenotificationID()); return; } #if DEBUG Console.WriteLine(mediaUrl); #endif Log.println(mediaUrl); // Check if media url has some value if (mediaUrl != null && mediaTitle != null) { // Start download video file DownloadFile(mediaUrl, mediaTitle, isVideo, file_extension); #if DEBUG Console.WriteLine("Start download"); #endif Log.println("Start download"); } else { #if DEBUG Console.WriteLine("File not found", title); #endif Log.println("File not found: " + title); publishnotification("File not found", title, uniquenotificationID()); return; } }