mirror of
https://github.com/AAndyProgram/SCrawler.git
synced 2026-03-14 15:52:18 +00:00
2023.9.19.0
YT: add priority download protocol
This commit is contained in:
@@ -6,6 +6,10 @@
|
|||||||
'
|
'
|
||||||
' This program is distributed in the hope that it will be useful,
|
' This program is distributed in the hope that it will be useful,
|
||||||
' but WITHOUT ANY WARRANTY
|
' but WITHOUT ANY WARRANTY
|
||||||
|
Imports System.Drawing.Design
|
||||||
|
Imports System.ComponentModel
|
||||||
|
Imports PersonalUtilities.Tools.Grid.Attributes
|
||||||
|
Imports PersonalUtilities.Tools.Grid.EnumObjects
|
||||||
Namespace API.YouTube.Base
|
Namespace API.YouTube.Base
|
||||||
Public Structure Thumbnail : Implements IIndexable, IComparable(Of Thumbnail)
|
Public Structure Thumbnail : Implements IIndexable, IComparable(Of Thumbnail)
|
||||||
Public ID As String
|
Public ID As String
|
||||||
@@ -47,6 +51,14 @@ Namespace API.YouTube.Base
|
|||||||
Channel = 2
|
Channel = 2
|
||||||
PlayList = 3
|
PlayList = 3
|
||||||
End Enum
|
End Enum
|
||||||
|
<Editor(GetType(EnumDropDownEditor), GetType(UITypeEditor))>
|
||||||
|
Public Enum Protocols As Integer
|
||||||
|
<EnumValue(ExcludeFromList:=True)>
|
||||||
|
Undefined = -1
|
||||||
|
Any = 0
|
||||||
|
https = 1
|
||||||
|
m3u8 = 2
|
||||||
|
End Enum
|
||||||
Public Structure MediaObject : Implements IIndexable, IComparable(Of MediaObject)
|
Public Structure MediaObject : Implements IIndexable, IComparable(Of MediaObject)
|
||||||
Public Type As Plugin.UserMediaTypes
|
Public Type As Plugin.UserMediaTypes
|
||||||
Public ID As String
|
Public ID As String
|
||||||
@@ -59,6 +71,17 @@ Namespace API.YouTube.Base
|
|||||||
Public Size As Double
|
Public Size As Double
|
||||||
Public Codec As String
|
Public Codec As String
|
||||||
Public Protocol As String
|
Public Protocol As String
|
||||||
|
Public ReadOnly Property ProtocolType As Protocols
|
||||||
|
Get
|
||||||
|
If Not Protocol.IsEmptyString Then
|
||||||
|
Select Case Protocol.StringToLower.StringTrim
|
||||||
|
Case "http", "https" : Return Protocols.https
|
||||||
|
Case "m3u8" : Return Protocols.m3u8
|
||||||
|
End Select
|
||||||
|
End If
|
||||||
|
Return Protocols.Undefined
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
Public URL As String
|
Public URL As String
|
||||||
Public Property Index As Integer Implements IIndexable.Index
|
Public Property Index As Integer Implements IIndexable.Index
|
||||||
Private Function SetIndex(ByVal Obj As Object, ByVal Index As Integer) As Object Implements IIndexable.SetIndex
|
Private Function SetIndex(ByVal Obj As Object, ByVal Index As Integer) As Object Implements IIndexable.SetIndex
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ Namespace API.YouTube.Base
|
|||||||
<Browsable(True), GridVisible, XMLVN({"Defaults"}), Category("Defaults"), DisplayName("Use cookies"),
|
<Browsable(True), GridVisible, XMLVN({"Defaults"}), Category("Defaults"), DisplayName("Use cookies"),
|
||||||
Description("By default, use cookies when downloading from YouTube.")>
|
Description("By default, use cookies when downloading from YouTube.")>
|
||||||
Public ReadOnly Property DefaultUseCookies As XMLValue(Of Boolean)
|
Public ReadOnly Property DefaultUseCookies As XMLValue(Of Boolean)
|
||||||
|
<Browsable(True), GridVisible, XMLVN({"Defaults"}, Protocols.Any), Category("Defaults"), DisplayName("Protocol"),
|
||||||
|
Description("Priority download protocol. Default: 'Any'")>
|
||||||
|
Public ReadOnly Property DefaultProtocol As XMLValue(Of Protocols)
|
||||||
<Browsable(True), GridVisible(False), XMLVN({"Defaults"}), Category("Defaults"),
|
<Browsable(True), GridVisible(False), XMLVN({"Defaults"}), Category("Defaults"),
|
||||||
DisplayName("Auto remove"), Description("Automatically remove downloaded items from the list.")>
|
DisplayName("Auto remove"), Description("Automatically remove downloaded items from the list.")>
|
||||||
Public ReadOnly Property RemoveDownloadedAutomatically As XMLValue(Of Boolean)
|
Public ReadOnly Property RemoveDownloadedAutomatically As XMLValue(Of Boolean)
|
||||||
|
|||||||
@@ -1309,9 +1309,29 @@ Namespace API.YouTube.Objects
|
|||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
Dim protocolCleaner As Action =
|
||||||
|
Sub()
|
||||||
|
If Not MyYouTubeSettings.DefaultProtocol.Value = Protocols.Undefined And
|
||||||
|
Not MyYouTubeSettings.DefaultProtocol.Value = Protocols.Any Then
|
||||||
|
Dim data As New List(Of MediaObject)(MediaObjects.Where(Function(mo) mo.ProtocolType = MyYouTubeSettings.DefaultProtocol.Value))
|
||||||
|
If data.ListExists Then
|
||||||
|
Dim dRem As Protocols = IIf(MyYouTubeSettings.DefaultProtocol.Value = Protocols.https, Protocols.m3u8, Protocols.https)
|
||||||
|
Dim d As MediaObject
|
||||||
|
Dim dr As New FPredicate(Of MediaObject)(Function(mo) mo.Height = d.Height And mo.ProtocolType = dRem)
|
||||||
|
For Each d In data
|
||||||
|
If MediaObjects.Count = 0 Then
|
||||||
|
Exit For
|
||||||
|
ElseIf MediaObjects.LongCount(dr) > 0 Then
|
||||||
|
MediaObjects.RemoveAll(dr)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
If MediaObjects.Count > 0 And Not MyYouTubeSettings.DefaultVideoIncludeNullSize Then MediaObjects.RemoveAll(Function(mo) mo.Size <= 0)
|
If MediaObjects.Count > 0 And Not MyYouTubeSettings.DefaultVideoIncludeNullSize Then MediaObjects.RemoveAll(Function(mo) mo.Size <= 0)
|
||||||
If MediaObjects.Count > 0 Then DupRemover.Invoke(UMTypes.Audio)
|
If MediaObjects.Count > 0 Then DupRemover.Invoke(UMTypes.Audio)
|
||||||
If MediaObjects.Count > 0 Then DupRemover.Invoke(UMTypes.Video)
|
If MediaObjects.Count > 0 Then DupRemover.Invoke(UMTypes.Video)
|
||||||
|
If MediaObjects.Count > 0 Then protocolCleaner.Invoke
|
||||||
If MediaObjects.Count > 0 Then
|
If MediaObjects.Count > 0 Then
|
||||||
MediaObjects.Sort()
|
MediaObjects.Sort()
|
||||||
SelectedAudioIndex = MediaObjects.FindIndex(Function(mo) mo.Type = UMTypes.Audio)
|
SelectedAudioIndex = MediaObjects.FindIndex(Function(mo) mo.Type = UMTypes.Audio)
|
||||||
|
|||||||
Reference in New Issue
Block a user