mirror of
https://github.com/AAndyProgram/SCrawler.git
synced 2026-03-14 15:52:18 +00:00
2023.8.27.0
YT: fix 'Shorts' downloading
This commit is contained in:
@@ -23,17 +23,19 @@ Namespace API.YouTube.Base
|
|||||||
Public Shared Function IsMyUrl(ByVal URL As String) As Boolean
|
Public Shared Function IsMyUrl(ByVal URL As String) As Boolean
|
||||||
Return Not Info_GetUrlType(URL) = YouTubeMediaType.Undefined
|
Return Not Info_GetUrlType(URL) = YouTubeMediaType.Undefined
|
||||||
End Function
|
End Function
|
||||||
Public Shared Function Info_GetUrlType(ByVal URL As String, Optional ByRef IsMusic As Boolean = False,
|
Public Shared Function Info_GetUrlType(ByVal URL As String, Optional ByRef IsMusic As Boolean = False, Optional ByRef IsShorts As Boolean = False,
|
||||||
Optional ByRef IsChannelUser As Boolean = False, Optional ByRef Id As String = Nothing) As YouTubeMediaType
|
Optional ByRef IsChannelUser As Boolean = False, Optional ByRef Id As String = Nothing) As YouTubeMediaType
|
||||||
If Not URL.IsEmptyString Then
|
If Not URL.IsEmptyString Then
|
||||||
IsMusic = URL.Contains("music.youtube.com")
|
IsMusic = URL.Contains("music.youtube.com")
|
||||||
IsChannelUser = False
|
IsChannelUser = False
|
||||||
|
IsShorts = False
|
||||||
Dim data As List(Of String) = RegexReplace(URL, RParams.DMS(UrlTypePattern, 0, RegexReturn.ListByMatch, EDP.ReturnValue))
|
Dim data As List(Of String) = RegexReplace(URL, RParams.DMS(UrlTypePattern, 0, RegexReturn.ListByMatch, EDP.ReturnValue))
|
||||||
If data.ListExists Then
|
If data.ListExists Then
|
||||||
If data.Count >= 6 Then Id = data(5)
|
If data.Count >= 6 Then Id = data(5)
|
||||||
If data.Count >= 3 And Not data(2).IsEmptyString Then
|
If data.Count >= 3 And Not data(2).IsEmptyString Then
|
||||||
Select Case data(2).ToLower
|
Select Case data(2).ToLower
|
||||||
Case "watch" : Return YouTubeMediaType.Single
|
Case "watch" : Return YouTubeMediaType.Single
|
||||||
|
Case "shorts" : IsShorts = True : Return YouTubeMediaType.Single
|
||||||
Case "playlist" : Return YouTubeMediaType.PlayList
|
Case "playlist" : Return YouTubeMediaType.PlayList
|
||||||
Case UserChannelOption, "@" : IsChannelUser = data(2).ToLower = UserChannelOption : Return YouTubeMediaType.Channel
|
Case UserChannelOption, "@" : IsChannelUser = data(2).ToLower = UserChannelOption : Return YouTubeMediaType.Channel
|
||||||
End Select
|
End Select
|
||||||
@@ -64,8 +66,8 @@ Namespace API.YouTube.Base
|
|||||||
Dim urlOrig$ = URL
|
Dim urlOrig$ = URL
|
||||||
URL = RegexReplace(URL, TrueUrlRegEx)
|
URL = RegexReplace(URL, TrueUrlRegEx)
|
||||||
If URL.IsEmptyString Then Throw New ArgumentNullException("URL", $"Can't get true URL from [{urlOrig}]")
|
If URL.IsEmptyString Then Throw New ArgumentNullException("URL", $"Can't get true URL from [{urlOrig}]")
|
||||||
Dim isMusic As Boolean = False
|
Dim isMusic As Boolean = False, isShorts As Boolean = False
|
||||||
Dim objType As YouTubeMediaType = Info_GetUrlType(URL, isMusic)
|
Dim objType As YouTubeMediaType = Info_GetUrlType(URL, isMusic, isShorts)
|
||||||
If Not objType = YouTubeMediaType.Undefined Then
|
If Not objType = YouTubeMediaType.Undefined Then
|
||||||
Dim __GetDefault As Boolean = If(GetDefault, True)
|
Dim __GetDefault As Boolean = If(GetDefault, True)
|
||||||
Dim __GetShorts As Boolean = If(GetShorts, True)
|
Dim __GetShorts As Boolean = If(GetShorts, True)
|
||||||
@@ -105,7 +107,7 @@ Namespace API.YouTube.Base
|
|||||||
|
|
||||||
If result Then
|
If result Then
|
||||||
container.Parse(Nothing, _CachePathDefault, isMusic, Token, Progress)
|
container.Parse(Nothing, _CachePathDefault, isMusic, Token, Progress)
|
||||||
If Not container.HasError Then container.URL = URL : Return container
|
If Not container.HasError Then container.URL = URL : container.IsShorts = isShorts : Return container
|
||||||
End If
|
End If
|
||||||
container.Dispose()
|
container.Dispose()
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ Namespace API.YouTube.Objects
|
|||||||
ReadOnly Property MediaType As UMTypes
|
ReadOnly Property MediaType As UMTypes
|
||||||
ReadOnly Property MediaState As UMStates
|
ReadOnly Property MediaState As UMStates
|
||||||
Property IsMusic As Boolean
|
Property IsMusic As Boolean
|
||||||
|
Property IsShorts As Boolean
|
||||||
Property ID As String
|
Property ID As String
|
||||||
Property Description As String
|
Property Description As String
|
||||||
Property PlaylistID As String
|
Property PlaylistID As String
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ Namespace API.YouTube.Objects
|
|||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
<XMLEC(Name_IsMusic)> Public Property IsMusic As Boolean = False Implements IYouTubeMediaContainer.IsMusic
|
<XMLEC(Name_IsMusic)> Public Property IsMusic As Boolean = False Implements IYouTubeMediaContainer.IsMusic
|
||||||
<XMLEC> Public Property IsShorts As Boolean = False
|
<XMLEC> Public Property IsShorts As Boolean = False Implements IYouTubeMediaContainer.IsShorts
|
||||||
<XMLEC> Public Property ID As String Implements IYouTubeMediaContainer.ID, IUserMedia.PostID
|
<XMLEC> Public Property ID As String Implements IYouTubeMediaContainer.ID, IUserMedia.PostID
|
||||||
<XMLEC> Public Property Title As String Implements IDownloadableMedia.Title
|
<XMLEC> Public Property Title As String Implements IDownloadableMedia.Title
|
||||||
<XMLEC> Public Property Description As String Implements IYouTubeMediaContainer.Description
|
<XMLEC> Public Property Description As String Implements IYouTubeMediaContainer.Description
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Namespace API.YouTube
|
|||||||
Dim isMusic As Boolean = False
|
Dim isMusic As Boolean = False
|
||||||
Dim id$ = String.Empty
|
Dim id$ = String.Empty
|
||||||
Dim isChannelUser As Boolean = False
|
Dim isChannelUser As Boolean = False
|
||||||
Dim t As YouTubeMediaType = YouTubeFunctions.Info_GetUrlType(UserURL, isMusic, isChannelUser, id)
|
Dim t As YouTubeMediaType = YouTubeFunctions.Info_GetUrlType(UserURL, isMusic,, isChannelUser, id)
|
||||||
If Not t = YouTubeMediaType.Undefined And Not t = YouTubeMediaType.Single And Not id.IsEmptyString Then
|
If Not t = YouTubeMediaType.Undefined And Not t = YouTubeMediaType.Single And Not id.IsEmptyString Then
|
||||||
Return New ExchangeOptions(Site, $"{id}@{CInt(t) + IIf(isMusic, UserMedia.Types.Audio, 0) + IIf(isChannelUser, ChannelUserInt, 0)}")
|
Return New ExchangeOptions(Site, $"{id}@{CInt(t) + IIf(isMusic, UserMedia.Types.Audio, 0) + IIf(isChannelUser, ChannelUserInt, 0)}")
|
||||||
End If
|
End If
|
||||||
|
|||||||
Reference in New Issue
Block a user