private async void StartConvert(List <IParam> parameters) { string param = string.Join(" ", parameters.Select(e => $"{e.Key} {e.Value}")); List <Media> medias = Medias.Where(e => e.State != State.Finished).ToList(); tokenSource = new CancellationTokenSource(); IsWorking = true; try { foreach (Media media in medias) { await FFmpegConverter.ConvertAsync(media, parameters, tokenSource.Token); log.Info("finished"); } } catch (OperationCanceledException) { } finally { IsWorking = false; } }
public IEnumerable <ProductMedia> GetMediasWithUrl(MediaType type, Func <Media, string> getUrlFunc) { var result = Medias.Where(x => x.Media.MediaType == type); foreach (var item in result) { item.MediaUrl = getUrlFunc(item.Media); } return(result); }
public Media FindMediaByName(string name, string proprietaryname) { try { return(Medias .Where(h => h.Name == name) .First()); } catch (Exception e) { return(NullableMedia); } }
private void InitializeEntities(TweetMode tweetMode) { // NOTE: The STREAMING API and REST API does not provide the same JSON structure based on the TweetMode used. // // * STREAMING API : Adds a new ExtendedTweet regardless of the TweetMode. To have some consistency with the REST API, // we decided that in COMPAT mode, the Entities will be restricted to what is available in the REST API. // * REST API : Adds FullText and additional properties if the TweetMode is extended. var isTweetComingFromStreamingAPI = _tweetDTO?.ExtendedTweet != null; var useStreamingApiExtendedTweetForEntities = tweetMode == TweetMode.Extended && isTweetComingFromStreamingAPI; // Get the entities and extended_entities for whichever Tweet DTO we're using var entities = useStreamingApiExtendedTweetForEntities ? _tweetDTO.ExtendedTweet.LegacyEntities : _tweetDTO?.LegacyEntities; var extendedEntities = useStreamingApiExtendedTweetForEntities ? _tweetDTO.ExtendedTweet.ExtendedEntities : _tweetDTO?.Entities; // Populate for each type of entity. Urls = entities?.Urls; UserMentions = entities?.UserMentions; Hashtags = entities?.Hashtags; Symbols = entities?.Symbols; // Media can also be in the extended_entities field. https://dev.twitter.com/overview/api/entities-in-twitter-objects#extended_entities // If that's populated, we must use it instead or risk missing media Medias = extendedEntities?.Medias ?? entities?.Medias ?? new List <IMediaEntity>(); // If this is a retweet, it's also now possible for an entity to get cut off of the end of the tweet entirely. // If the same Tweet is fetched over the REST API, these entities get excluded, so lets do the same. if (_tweetDTO?.RetweetedTweetDTO != null) { Urls = Urls?.Where(e => e.Indices[0] != e.Indices[1]).ToList(); UserMentions = UserMentions?.Where(e => e.Indices[0] != e.Indices[1]).ToList(); Hashtags = Hashtags?.Where(e => e.Indices[0] != e.Indices[1]).ToList(); Symbols = Symbols?.Where(e => e.Indices[0] != e.Indices[1]).ToList(); Medias = Medias?.Where(e => e.Indices[0] != e.Indices[1]).ToList(); } }