internal FilterTagsForm(GlobalCatAndTagsList sourceTags, TagsFilter tagsFilter) { InitializeComponent(); SourceTags = new GlobalCatAndTagsList(sourceTags.Count); #region Arrow buttons setup // Because this form isn't loading on startup, I'm being lazy here and just creating a bitmap using (var g = Graphics.FromImage(_arrowRightBmp)) { Point[] arrowPolygon = { // -1 works?! (and for some reason is needed?!) new Point(2, -1), new Point(2, 7), new Point(6, 3) }; g.FillPolygon(Brushes.Black, arrowPolygon); } AndButton.Image = _arrowRightBmp; OrButton.Image = _arrowRightBmp; NotButton.Image = _arrowRightBmp; #endregion sourceTags.DeepCopyTo(SourceTags); tagsFilter.DeepCopyTo(TagsFilter); Localize(); }
private bool ShouldFilterTag(FLVTag tag, TagsFilter filterTags) { if (tag == null) { return(true); } // if the timestamp is lower than the current time if (_currentTime != INVALID_TIME && tag.Timestamp < _currentTime) { tag.Timestamp = _currentTime; //return true; } switch (tag.Type) { case FLVTag.TagType.AUDIO: case FLVTag.TagType.AKAMAI_ENC_AUDIO: return((TagsFilter.AUDIO & filterTags) == 0 || (_alternateTime != INVALID_TIME && tag.Timestamp < _alternateTime)); case FLVTag.TagType.VIDEO: case FLVTag.TagType.AKAMAI_ENC_VIDEO: return((TagsFilter.VIDEO & filterTags) == 0 || (_mediaTime != INVALID_TIME && tag.Timestamp < _mediaTime)); } return(true); }
/// <summary> /// 单维度扩展接口 /// </summary> public string TagsEx(TagsFilter filter) { try { var tags = TagCache.Instance.Items[new TagNodeKey() { Dimension = filter.dimension, Type = filter.type }]; var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var xml = new XElement("tags"); var filters = VideoNodesUtil.FormateVodFilter(filter); xml.Add(from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select new XElement("tag", new XElement("name", tag.Language[filter.lang].Title), new XElement("count", count) )); return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
internal FilterTagsForm(FMCategoriesCollection sourceTags, TagsFilter tagsFilter) { #if DEBUG InitializeComponent(); #else InitializeComponentSlim(); #endif tagsFilter.DeepCopyTo(TagsFilter); if (Config.DarkMode) { SetThemeBase(Config.VisualTheme); } Localize(); var tv = OriginTreeView; try { tv.BeginUpdate(); ControlUtils.FillTreeViewFromTags_Sorted(tv, sourceTags); tv.ExpandAll(); tv.SelectedNode = tv.Nodes[0]; } finally { tv.EndUpdate(); } if (TagsFilter.AndTags.Count > 0) { FillTreeView(TagsFilter.AndTags); } if (TagsFilter.OrTags.Count > 0) { FillTreeView(TagsFilter.OrTags); } if (TagsFilter.NotTags.Count > 0) { FillTreeView(TagsFilter.NotTags); } }
/// <summary> /// 分类扩展接口 /// </summary> public string VideoTypesEx(TagsFilter filter) { try { var types = BoxTypeCache.Instance.Items; var filters = VideoNodesUtil.CommonFilter(filter); var root = new XElement("types"); foreach (var boxtype in types) { var videos = ListCache.Instance.Items[new VideoNodeKey(filter.platform, boxtype.Key, filter.auth)].OrderArray; int count = 0; for (var i = 0; i < videos.Count; i++) { bool result = true; var v = ListCache.Instance.Dictionary[videos[i]]; foreach (var f in filters) { result = result && f(v, filter); } if (result) { count++; } } root.Add(new XElement("type", new XElement("tid", boxtype.Value.TypeID), new XElement("name", boxtype.Value.Language[filter.lang].Title), new XElement("count", count), new XElement("image", boxtype.Value.PicLink), new XElement("tag_dimesion", boxtype.Value.ResponseDimension), new XElement("treeleft_support", boxtype.Value.TreeSupport) )); } return(root.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
/// <summary> /// 多维度基本接口 /// </summary> public string MultiTags(TagsFilter filter) { try { var dimensions = filter.dimension.Split(SplitArray.LineArray, StringSplitOptions.RemoveEmptyEntries).Distinct(); var filters = VideoNodesUtil.CommonCustomFilter(filter); var xml = new XElement("tags"); foreach (var dimension in dimensions) { var tags = TagCache.Instance.Items[new TagNodeKey() { Dimension = dimension, Type = filter.type }]; var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); IEnumerable <string> query = null; if (filters.Count <= 0) { query = from tag in tags where tag.Channels.ContainsKey(key) select tag.Language[filter.lang].Title; } else { query = from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select tag.Language[filter.lang].Title; } xml.Add(new XElement("info", new XAttribute("dimension", dimension), BoxUtils.GetXmlCData(query.FormatListToStr(SplitArray.Line, 100)) )); } return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
private int GetChannelCount(TagNode node, VideoNodeKey key, TagsFilter filter, List <Func <VideoBase, ExFilterBase, bool> > filters) { int count = 0; var cs = node.Channels[key]; foreach (var c in cs) { var result = true; var v = ListCache.Instance.Dictionary[c]; foreach (var f in filters) { result = result && f(v, filter); } if (result) { count++; } } return(count); }
/// <summary> /// 分类基本接口 /// </summary> public string VideoTypes(TagsFilter filter) { try { var xml = new XElement("types"); xml.Add(from boxtype in BoxTypeCache.Instance.Items.Values select new XElement("type", new XElement("tid", boxtype.TypeID), new XElement("name", boxtype.Language[filter.lang].Title), new XElement("image", boxtype.PicLink), new XElement("tag_dimesion", boxtype.ResponseDimension), new XElement("treeleft_support", boxtype.TreeSupport) )); return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
/// <summary> /// 多维度扩展接口 /// </summary> public string MultiTagsEx(TagsFilter filter) { try { var dimensions = filter.dimension.Split(SplitArray.LineArray, StringSplitOptions.RemoveEmptyEntries).Distinct(); var xml = new XElement("tags"); foreach (var dimension in dimensions) { var tags = TagCache.Instance.Items[new TagNodeKey() { Dimension = dimension, Type = filter.type }]; var key = new VideoNodeKey(filter.platform, filter.type, filter.auth); var dimensionxml = new XElement("dimension", new XAttribute("name", dimension)); var filters = VideoNodesUtil.FormateVodFilter(filter); dimensionxml.Add(from tag in tags where tag.Channels.ContainsKey(key) let count = GetChannelCount(tag, key, filter, filters) where count > 0 select new XElement("tag", new XElement("name", tag.Language[filter.lang].Title), new XElement("count", count) )); xml.Add(dimensionxml); } return(xml.ToString(SaveOptions.DisableFormatting)); } catch (KeyNotFoundException) { return(NoPlatForm()); } catch (Exception ex) { return(BoxUtils.FormatErrorMsg(ex)); } }
public void StartDownload(string manifestUrl) { GetManifestAndSelectMedia(manifestUrl); Program.Message("Waiting first fragment...\r"); // downloader already running in UpdateBootstrapInfo() DetermineAudioVideoPresentInDownloadedFragment(); var DecoderState = new DecoderLastState(); bool useAltAudio = selectedMediaAlt != null; TagsFilter tagFilter = TagsFilter.ALL; if (UpdateStatusTimer == null && !Program.isRedirected) { UpdateStatusTimer = new Timer(ShowDownloadStatus, null, 0, UpdateStatusInterval); } if (useAltAudio) { tagFilter = TagsFilter.VIDEO; // only video for main media if alternate media is selected } _currentTime = INVALID_TIME; _mediaTime = INVALID_TIME; _alternateTime = INVALID_TIME; droppedAudioFrames = 0; droppedVideoFrames = 0; FLVTag mediaTag = null; FLVTag alternateTag = null; bool needSynchronizationAudio = true; if (!Program.ConsolePresent && Program.isRedirected) { Program.Message("Processing..."); } // --------------- MAIN LOOP DECODE FRAGMENTS ---------------- while (Downloader.TagsAvaliable(selectedMedia) || selectedMedia.Bootstrap.live) { if (mediaTag == null) { mediaTag = Downloader.GetNextTag(selectedMedia); if (mediaTag == null) { Thread.Sleep(100); // for decrease CPU load } } if (useAltAudio && _mediaTime != INVALID_TIME && Downloader.TagsAvaliable(selectedMediaAlt)) { if (alternateTag == null) { alternateTag = Downloader.GetNextTag(selectedMediaAlt); } if (useAltAudio && alternateTag != null && alternateTag.IsAkamaiEncrypted) { if (AD2 == null) // create and init only if need { AD2 = new AkamaiDecryptor(); } AD2.DecryptFLVTag(alternateTag, manifest.baseURL, auth); } if (needSynchronizationAudio && (_mediaTime != INVALID_TIME || _alternateTime != INVALID_TIME)) { uint alternateSynchronizationTime = _alternateTime != INVALID_TIME ? _alternateTime : _mediaTime; alternateTag = Downloader.SeekAudioByTime(selectedMediaAlt, alternateSynchronizationTime); if (alternateTag != null) { needSynchronizationAudio = false; } } } if (mediaTag != null && mediaTag.IsAkamaiEncrypted) { if (AD1 == null) // create and init only if need { AD1 = new AkamaiDecryptor(); } AD1.DecryptFLVTag(mediaTag, manifest.baseURL, auth); } if (useAltAudio && alternateTag != null && alternateTag.IsAkamaiEncrypted) { if (AD2 == null) // create and init only if need { AD2 = new AkamaiDecryptor(); } AD2.DecryptFLVTag(alternateTag, manifest.baseURL, auth); } if (ShouldFilterTag(mediaTag, tagFilter)) { if (mediaTag != null) { if (mediaTag is FLVTagVideo) { droppedVideoFrames++; } totalDroppedFrames++; } mediaTag = null; } else { UpdateTimes(mediaTag); } if (ShouldFilterTag(alternateTag, TagsFilter.AUDIO)) { if (alternateTag != null) { droppedAudioFrames++; totalDroppedFrames++; } alternateTag = null; } else { UpdateTimes(alternateTag); } if (!useAltAudio) { if (mediaTag != null) { _currentTime = mediaTag.Timestamp; FLVFile.Write(mediaTag); mediaTag = null; } } else { if (_mediaTime != INVALID_TIME || _alternateTime != INVALID_TIME) { if (alternateTag != null && (alternateTag.Timestamp >= _currentTime || _currentTime == INVALID_TIME) && (alternateTag.Timestamp <= _mediaTime)) { _currentTime = alternateTag.Timestamp; FLVFile.Write(alternateTag); alternateTag = null; } else if (mediaTag != null && (mediaTag.Timestamp >= _currentTime || _currentTime == INVALID_TIME) && (mediaTag.Timestamp <= _alternateTime)) { _currentTime = mediaTag.Timestamp; FLVFile.Write(mediaTag); mediaTag = null; } } } if ((duration > 0) && (FLVFile.LastTimestamp >= duration)) { Status = "Duration limit reached"; break; } if ((filesize > 0) && (FLVFile.Filesize >= filesize)) { Status = "File size limit reached"; break; } } DestroyUpdateStatusTimer(); ShowDownloadStatus(); }