public void onVideoAdWatched(VideoResult result) { if (result == VideoResult.RewardPlayer) { RewardFunction(); } }
private void onAdWatched(VideoResult result) { if (result.Success) { AdsData customData = (AdsData)result.CustomData; Player player = GameLogic.Binder.GameState.Player; if (customData.AdCategory == AdsData.Category.VENDOR) { player.DailyAdCountVendor++; } else if (customData.AdCategory == AdsData.Category.ADVENTURE_MYSTERY) { player.DailyAdCountMystery++; } else if (customData.AdCategory == AdsData.Category.TOURNAMENT_MYSTERY) { if (player.Tournaments.hasTournamentSelected()) { TournamentInstance selectedTournament = player.Tournaments.SelectedTournament; selectedTournament.DailyAdCountMystery++; } } else if ((customData.AdCategory == AdsData.Category.TOURNAMENT_CARDS) && player.Tournaments.hasTournamentSelected()) { TournamentInstance instance2 = player.Tournaments.SelectedTournament; instance2.DailyAdCountCards++; } } }
public async Task <VideoResult> PostVideoAsync(string videoType, string privacy, string title, string description, string url) { if (string.IsNullOrEmpty(title)) { title = "---"; } if (string.IsNullOrEmpty(description)) { description = "---"; } var req = new KoobecaCreateVideoRequest() { auth_view = privacy, title = title, description = description, url = url, type = videoType }; var result = await PostKoobecaRequestAsync <VideoResult>(req); if (result == null) { result = new VideoResult() { error = true, message = "got null result" }; } else { result.error = result.status_code != 200; } return(result); }
public void AdWatched(VideoResult result) { if (this.OnAdWatched != null) { this.OnAdWatched(result); } }
public ActionResult Video(string url) { var vr = new VideoResult(); vr.Operation = VideoService.CreateOperation(url, new FaceDetectionOperationSettings()); return(View("Video", vr)); }
public ActionResult Video(string url) { var vr = new VideoResult(); vr.Operation = VideoService.FaceDetectionAndTracking(url); return(View("Video", vr)); }
public OnlineVideoWindow(VideoResult data) { InitializeComponent(); var browser = new ChromiumWebBrowser(); browser.Address = data.Link; browser.LifeSpanHandler = new LifeSpanHandler(); DataContext = browser; }
public static VideoResult CreateDVDInfo(string dvdTitle, MediaInfoWrapper videoTsInfo) { VideoResult result = new VideoResult(dvdTitle, videoTsInfo) { IsDVD = true, MimeType = "video/dvd" }; return(result); }
public ActionResult VideoOperation(string operationUrl) { var vr = new VideoResult(); vr.Operation = new Operation(operationUrl); vr.OperationResult = VideoService.GetOperationResult(new Operation(operationUrl)); return(View("Video", vr)); }
private void onAdWatched(VideoResult result) { if (result.Success) { AdsData customData = (AdsData)result.CustomData; Player player = GameLogic.Binder.GameState.Player; this.sendAdViewEvent(player, customData.AdReward, customData.AdZone, "finish"); this.sendCrmEvent(player, "crm_ad_view_watch"); } }
private async Task <ListVideos> GetVidsAsync() { var res = new ListVideos(); var result = new YoutubeResult(); try { res.lsVideos = new List <YoutubeAPIViewModel>(); var path = "https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails&maxResults=50&playlistId=PLAC325451207E3105&key=AIzaSyB7cEKc5O5lr9aF10Gr3ODo_AFbIGOjjHM"; HttpResponseMessage response = await client.GetAsync(path); if (response.IsSuccessStatusCode) { result = await response.Content.ReadAsAsync <YoutubeResult>(); foreach (var item in result.items) { var vidRes = new VideoResult(); var uri = $"https://www.googleapis.com/youtube/v3/videos?part=snippet%2CcontentDetails%2Cstatistics&id={item.contentDetails.videoId}&key=AIzaSyB7cEKc5O5lr9aF10Gr3ODo_AFbIGOjjHM"; HttpResponseMessage resp = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { vidRes = await resp.Content.ReadAsAsync <VideoResult>(); var you = new YoutubeAPIViewModel { Id = vidRes.items.FirstOrDefault().id, Title = vidRes.items.FirstOrDefault().snippet.title, Description = vidRes.items.FirstOrDefault().snippet.description, //Tumbnail = vidRes.items.FirstOrDefault().snippet.thumbnails.FirstOrDefault().medium.url }; res.lsVideos.Add(you); } } } } catch (Exception ex) { throw ex; } return(res); }
public async Task <List <Video> > GetVideos(string movieId) { try { VideoResult result = await $"{ENDPOINT}movie/{movieId}/videos?api_key={APIKEY}".GetJsonAsync <VideoResult>(); List <Video> videos = result.Videos.Where(v => v.Site == "YouTube" && v.Type == "Trailer").ToList(); return(videos); //return result.Videos; } catch (FlurlHttpException ex) { throw ex; } catch (Exception ex) { throw ex; } }
public void AddToVideoResultSet(VideoResult videoResult) { base.AddObject("VideoResultSet", videoResult); }
public static VideoResult CreateVideoResult(global::System.Guid ID) { VideoResult videoResult = new VideoResult(); videoResult.ID = ID; return videoResult; }
protected void ButtonUploadClick(object sender, EventArgs e) { // first, try and load original record if it is there var sessionVideoResult = SessionVideoManager.I.Get(new SessionVideoQuery {SessionId = SessionId}).FirstOrDefault(); var videoResult = new VideoResult(); if (sessionVideoResult != null) { videoResult = VideoManager.I.Get(new VideoQuery() {Id = sessionVideoResult.VideoId}).FirstOrDefault(); } // either there is a new file ... or there was a file previously loaded if ((FileUploadStaticImage.HasFile && SessionId > 0) || (videoResult != null && videoResult.PictureBytes.Length > 0)) { Stream stream = FileUploadStaticImage.FileContent; string fileName = FileUploadStaticImage.FileName; // first delete what might have been there before if (sessionVideoResult != null) { SessionVideoManager.I.Delete(sessionVideoResult.Id); VideoManager.I.Delete(videoResult.Id); } if (sessionVideoResult == null) { videoResult = new VideoResult() { CreatedDate = DateTime.Now }; sessionVideoResult = new SessionVideoResult { SessionId = SessionId.Value }; } if ((fileName.ToLower().EndsWith("jpg") || fileName.ToLower().EndsWith("png")) && FileUploadStaticImage.HasFile) { int iLen = Convert.ToInt32(stream.Length); var uploadedByteArray = new byte[iLen]; stream.Read(uploadedByteArray, 0, iLen); videoResult.PictureBytes = uploadedByteArray; } if (!String.IsNullOrEmpty(TextBoxDescrText.Text)) { videoResult.DescriptionText = TextBoxDescrText.Text; } if (!String.IsNullOrEmpty(TextBoxYoutubeURL.Text)) { videoResult.YouTubeURL = TextBoxYoutubeURL.Text; } VideoManager.I.Insert(videoResult); sessionVideoResult.VideoId = videoResult.Id; SessionVideoManager.I.Insert(sessionVideoResult); DeleteCache(); } }
//private static int ThreadCount = 0; private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var argument = (ConversionTaskParameters)e.Argument; BackgroundWorker backgroundWorker = argument.BackgroundWorker; backgroundWorker.ReportProgress(0, "Waiting in queue"); semaphore.Wait(); //while (ThreadCount>=2) //{ // backgroundWorker.ReportProgress(0,"Waiting in queue"); // Thread.Sleep(5000); //} ////ThreadCount++; //Interlocked.Increment(ref ThreadCount); //this.CreateDownloadFolder(); if (argument.ConversionProfile != null) { string fileNameWithoutExtension; string uRL; string str3; if (argument.OriginalFileLocation == null) { throw new Exception("Incorect video location specified"); } var result = new VideoResult(); bool flag = false; if ( Regex.Match(argument.OriginalFileLocation, @"(?:[Yy][Oo][Uu][Tt][Uu][Bb][Ee]\.[Cc][Oo][Mm]/((?:(?:(?:watch)|(?:watch_popup))(?:(?:\?|\#|\!|\&)?[\w]*=[\w]*)*(?:\?|\#|\!|\&)?v=(?<vid>-?[\w|-]*))|(?:v/(?<vid>-?[\w|-]*))))|(?:[Yy][Oo][Uu][Tt][Uu].[Bb][Ee]/(?<vid>-?[\w|-]*))") .Success) { string str4; backgroundWorker.ReportProgress(0, "Determining location of the video stream"); var u = new YouTubeDownloader.YouTubeDownloader(); ResourceLocation location = u.ResolveVideoURL(argument.OriginalFileLocation, argument.QualityIndex, argument.ConversionProfile.PreferedType, out str4); if ((location == null) || string.IsNullOrEmpty(location.URL)) { throw new Exception("Unable to obtain initial information about this video"); } flag = ((argument.ConversionProfile.PreferedType != YouTubeDownloader.YouTubeDownloader.VideoStreamTypes.Any) && !string.IsNullOrEmpty(argument.ConversionProfile.AlternativeConversionString)) && (location.StreamType != argument.ConversionProfile.PreferedType); str3 = !flag ? argument.ConversionProfile.ConversionStringTemplate : argument.ConversionProfile.AlternativeConversionString; uRL = location.URL; fileNameWithoutExtension = TextUtil.FormatFileName(str4); result.Title = str4; } else { fileNameWithoutExtension = Path.GetFileNameWithoutExtension(argument.OriginalFileLocation); uRL = argument.OriginalFileLocation; result.Title = fileNameWithoutExtension; result.FileSize = new FileInfo(argument.OriginalFileLocation).Length; str3 = !string.IsNullOrEmpty(argument.ConversionProfile.ConversionStringTemplate) ? argument.ConversionProfile.ConversionStringTemplate : argument.ConversionProfile.AlternativeConversionString; } backgroundWorker.ReportProgress(0, "***" + fileNameWithoutExtension); string str5 = string.Format("{0}.{1}", fileNameWithoutExtension, argument.ConversionProfile.OutputExtension); string str6 = DateTime.Now.Ticks.ToString(); string targetTmpFile = Path.Combine(ApplicationSettings.Instance.DefaultDownloadFolder, str6); string targetFile = Path.Combine(ApplicationSettings.Instance.DefaultDownloadFolder, str5); if (File.Exists(targetFile)) { backgroundWorker.ReportProgress(0, "Exist file:" + fileNameWithoutExtension); return; } long resultSize = 0L; result.ResultPath = targetFile; if (((argument.ConversionProfile.ConversionStringTemplate != null) || flag) && !argument.IndirectConversion) { try { e.Cancel = DownloadHelper.DownloadAndConvert(backgroundWorker, str3, uRL, targetFile, targetTmpFile, out resultSize); } catch (Exception exception) { resultSize = 0L; result.ResultException = exception; } } else { e.Cancel = DownloadHelper.InternalDownload(backgroundWorker, str3, uRL, targetFile, targetTmpFile, out resultSize); } result.FileSize = resultSize; e.Result = result; try { DownloadSubtitle(uRL, fileNameWithoutExtension); } catch (Exception ex) { //todo } } }
public static VideoResult CreateDVDInfo(string dvdTitle, MediaInfoWrapper videoTsInfo) { VideoResult result = new VideoResult(dvdTitle, videoTsInfo) { IsDVD = true, MimeType = "video/dvd" }; return result; }
public bool TryExtractMetadata(IResourceAccessor mediaItemAccessor, IDictionary <Guid, MediaItemAspect> extractedAspectData, bool forceQuickMode) { try { VideoResult result = null; IFileSystemResourceAccessor fsra = mediaItemAccessor as IFileSystemResourceAccessor; if (fsra != null && fsra.IsDirectory && fsra.ResourceExists("VIDEO_TS")) { IFileSystemResourceAccessor fsraVideoTs = fsra.GetResource("VIDEO_TS"); if (fsraVideoTs != null && fsraVideoTs.ResourceExists("VIDEO_TS.IFO")) { // Video DVD using (MediaInfoWrapper videoTsInfo = ReadMediaInfo(fsraVideoTs.GetResource("VIDEO_TS.IFO"))) { if (!videoTsInfo.IsValid || videoTsInfo.GetVideoCount() == 0) { return(false); // Invalid video_ts.ifo file } result = VideoResult.CreateDVDInfo(fsra.ResourceName, videoTsInfo); } // Iterate over all video files; MediaInfo finds different audio/video metadata for each .ifo file ICollection <IFileSystemResourceAccessor> files = fsraVideoTs.GetFiles(); if (files != null) { foreach (IFileSystemResourceAccessor file in files) { string lowerPath = (file.ResourcePathName ?? string.Empty).ToLowerInvariant(); if (!lowerPath.EndsWith(".ifo") || lowerPath.EndsWith("video_ts.ifo")) { continue; } using (MediaInfoWrapper mediaInfo = ReadMediaInfo(file)) { // Before we start evaluating the file, check if it is a video at all if (mediaInfo.IsValid && mediaInfo.GetVideoCount() == 0) { continue; } result.AddMediaInfo(mediaInfo); } } } } } else if (mediaItemAccessor.IsFile) { string filePath = mediaItemAccessor.ResourcePathName; if (!HasVideoExtension(filePath)) { return(false); } using (MediaInfoWrapper fileInfo = ReadMediaInfo(mediaItemAccessor)) { // Before we start evaluating the file, check if it is a video at all if (!fileInfo.IsValid || (fileInfo.GetVideoCount() == 0 && !IsWorkaroundRequired(filePath))) { return(false); } string mediaTitle = DosPathHelper.GetFileNameWithoutExtension(mediaItemAccessor.ResourceName); result = VideoResult.CreateFileInfo(mediaTitle, fileInfo); } using (Stream stream = mediaItemAccessor.OpenRead()) result.MimeType = MimeTypeDetector.GetMimeType(stream); } if (result != null) { result.UpdateMetadata(extractedAspectData); ILocalFsResourceAccessor disposeLfsra = null; try { ILocalFsResourceAccessor lfsra = mediaItemAccessor as ILocalFsResourceAccessor; if (lfsra == null && !forceQuickMode) { // In case forceQuickMode, we only want local browsing IResourceAccessor ra = mediaItemAccessor.Clone(); try { lfsra = StreamedResourceToLocalFsAccessBridge.GetLocalFsResourceAccessor(ra); disposeLfsra = lfsra; // Remember to dispose the extra resource accessor instance } catch (Exception) { ra.Dispose(); } } if (lfsra != null) { string localFsPath = lfsra.LocalFileSystemPath; ExtractMatroskaTags(localFsPath, extractedAspectData, forceQuickMode); ExtractThumbnailData(localFsPath, extractedAspectData, forceQuickMode); } } finally { if (disposeLfsra != null) { disposeLfsra.Dispose(); } } return(true); } } catch (Exception e) { // Only log at the info level here - And simply return false. This lets the caller know that we // couldn't perform our task here. ServiceRegistration.Get <ILogger>().Info("VideoMetadataExtractor: Exception reading resource '{0}' (Text: '{1}')", mediaItemAccessor.CanonicalLocalResourcePath, e.Message); } return(false); }
public bool TryExtractMetadata(IResourceAccessor mediaItemAccessor, IDictionary <Guid, MediaItemAspect> extractedAspectData, bool forceQuickMode) { try { VideoResult result = null; IFileSystemResourceAccessor fsra = mediaItemAccessor as IFileSystemResourceAccessor; if (fsra == null) { return(false); } if (!fsra.IsFile && fsra.ResourceExists("VIDEO_TS")) { IFileSystemResourceAccessor fsraVideoTs = fsra.GetResource("VIDEO_TS"); if (fsraVideoTs != null && fsraVideoTs.ResourceExists("VIDEO_TS.IFO")) { // Video DVD using (MediaInfoWrapper videoTsInfo = ReadMediaInfo(fsraVideoTs.GetResource("VIDEO_TS.IFO"))) { if (!videoTsInfo.IsValid || videoTsInfo.GetVideoCount() == 0) { return(false); // Invalid video_ts.ifo file } result = VideoResult.CreateDVDInfo(fsra.ResourceName, videoTsInfo); } // Iterate over all video files; MediaInfo finds different audio/video metadata for each .ifo file ICollection <IFileSystemResourceAccessor> files = fsraVideoTs.GetFiles(); if (files != null) { foreach (IFileSystemResourceAccessor file in files) { string lowerPath = (file.ResourcePathName ?? string.Empty).ToLowerInvariant(); if (!lowerPath.EndsWith(".ifo") || lowerPath.EndsWith("video_ts.ifo")) { continue; } using (MediaInfoWrapper mediaInfo = ReadMediaInfo(file)) { // Before we start evaluating the file, check if it is a video at all if (mediaInfo.IsValid && mediaInfo.GetVideoCount() == 0) { continue; } result.AddMediaInfo(mediaInfo); } } } } } else if (fsra.IsFile) { string filePath = fsra.ResourcePathName; if (!HasVideoExtension(filePath)) { return(false); } using (MediaInfoWrapper fileInfo = ReadMediaInfo(fsra)) { // Before we start evaluating the file, check if it is a video at all if (!fileInfo.IsValid || (fileInfo.GetVideoCount() == 0 && !IsWorkaroundRequired(filePath))) { return(false); } string mediaTitle = DosPathHelper.GetFileNameWithoutExtension(fsra.ResourceName); result = VideoResult.CreateFileInfo(mediaTitle, fileInfo); } using (Stream stream = fsra.OpenRead()) result.MimeType = MimeTypeDetector.GetMimeType(stream, DEFAULT_MIMETYPE); } if (result != null) { result.UpdateMetadata(extractedAspectData); using (LocalFsResourceAccessorHelper rah = new LocalFsResourceAccessorHelper(mediaItemAccessor)) { ILocalFsResourceAccessor lfsra = rah.LocalFsResourceAccessor; if (lfsra != null) { MediaItemAspect.SetAttribute(extractedAspectData, MediaAspect.ATTR_SIZE, lfsra.Size); MediaItemAspect.SetAttribute(extractedAspectData, MediaAspect.ATTR_RECORDINGTIME, lfsra.LastChanged); ExtractMatroskaTags(lfsra, extractedAspectData, forceQuickMode); ExtractMp4Tags(lfsra, extractedAspectData, forceQuickMode); ExtractThumbnailData(lfsra, extractedAspectData, forceQuickMode); } return(true); } } } catch (Exception e) { // Only log at the info level here - And simply return false. This lets the caller know that we // couldn't perform our task here. ServiceRegistration.Get <ILogger>().Info("VideoMetadataExtractor: Exception reading resource '{0}' (Text: '{1}')", mediaItemAccessor.CanonicalLocalResourcePath, e.Message); } return(false); }