mirror of
https://github.com/AAndyProgram/SCrawler.git
synced 2026-03-14 15:52:18 +00:00
2023.11.12.1
YouTube: add cc and subtitles merge
This commit is contained in:
@@ -28,8 +28,19 @@ Namespace API.YouTube.Base
|
|||||||
End Structure
|
End Structure
|
||||||
Public Structure Subtitles : Implements IIndexable, IComparable(Of Subtitles)
|
Public Structure Subtitles : Implements IIndexable, IComparable(Of Subtitles)
|
||||||
Public ID As String
|
Public ID As String
|
||||||
Public Name As String
|
Private _Name As String
|
||||||
|
Public Property Name As String
|
||||||
|
Get
|
||||||
|
Dim n$ = _Name.IfNullOrEmpty(ID)
|
||||||
|
If CC Then n &= " (CC)"
|
||||||
|
Return n
|
||||||
|
End Get
|
||||||
|
Set(ByVal NewName As String)
|
||||||
|
_Name = NewName
|
||||||
|
End Set
|
||||||
|
End Property
|
||||||
Public Formats As String
|
Public Formats As String
|
||||||
|
Public CC As Boolean
|
||||||
Public ReadOnly Property FullID As String
|
Public ReadOnly Property FullID As String
|
||||||
Get
|
Get
|
||||||
Return IIf(ID = "en", "en.*", ID)
|
Return IIf(ID = "en", "en.*", ID)
|
||||||
|
|||||||
@@ -1422,28 +1422,36 @@ Namespace API.YouTube.Objects
|
|||||||
Protected Sub ParseSubtitles(ByVal e As EContainer)
|
Protected Sub ParseSubtitles(ByVal e As EContainer)
|
||||||
Dim subt As Subtitles
|
Dim subt As Subtitles
|
||||||
Dim ee As EContainer
|
Dim ee As EContainer
|
||||||
Dim se As EContainer = e({"subtitles"})
|
Dim eSUB As EContainer = e({"subtitles"})
|
||||||
If If(se?.Count, 0) = 0 OrElse (se.Count = 1 And se(0).Name = "live_chat") Then se = e({"automatic_captions"})
|
Dim eCC As EContainer = e({"automatic_captions"})
|
||||||
If If(se?.Count, 0) > 0 Then
|
If If(eSUB?.Count, 0) = 0 OrElse (eSUB.Count = 1 And eSUB(0).Name = "live_chat") Then eSUB = Nothing
|
||||||
If se.Count > 1 OrElse Not se(0).Name = "live_chat" Then
|
If If(eCC?.Count, 0) = 0 OrElse (eCC.Count = 1 And eCC(0).Name = "live_chat") Then eCC = Nothing
|
||||||
|
If If(eSUB?.Count, 0) > 0 Or If(eCC?.Count, 0) > 0 Then
|
||||||
|
Dim sl As New List(Of EContainer)
|
||||||
|
Dim ccExists As Boolean = False
|
||||||
|
Dim ccIndx% = -1, rIndx% = -1
|
||||||
|
If If(eSUB?.Count, 0) > 0 Then sl.Add(eSUB) : ccIndx += 1
|
||||||
|
If If(eCC?.Count, 0) > 0 Then sl.Add(eCC) : ccIndx += 1 : ccExists = True
|
||||||
|
For Each se As EContainer In sl
|
||||||
|
rIndx += 1
|
||||||
For Each ee In se
|
For Each ee In se
|
||||||
subt = New Subtitles With {.ID = ee.Name}
|
subt = New Subtitles With {.ID = ee.Name, .CC = rIndx = ccIndx And ccExists}
|
||||||
If ee.Count > 0 Then
|
If ee.Count > 0 Then
|
||||||
subt.Name = ee(0).Value("name")
|
subt.Name = ee(0).Value("name")
|
||||||
subt.Formats = ee.Select(Function(f) f.Value("ext")).ListToString(",")
|
subt.Formats = ee.Select(Function(f) f.Value("ext")).ListToString(",")
|
||||||
End If
|
End If
|
||||||
If Not subt.ID.IsEmptyString Then _Subtitles.Add(subt)
|
If Not subt.ID.IsEmptyString Then _Subtitles.Add(subt)
|
||||||
Next
|
Next
|
||||||
With MyYouTubeSettings
|
Next
|
||||||
If Not .DefaultSubtitlesFormat.IsEmptyString Then OutputSubtitlesFormat = .DefaultSubtitlesFormat
|
With MyYouTubeSettings
|
||||||
If _Subtitles.Count > 0 And .DefaultSubtitles.Count > 0 Then
|
If Not .DefaultSubtitlesFormat.IsEmptyString Then OutputSubtitlesFormat = .DefaultSubtitlesFormat
|
||||||
_Subtitles.Sort()
|
If _Subtitles.Count > 0 And .DefaultSubtitles.Count > 0 Then
|
||||||
_Subtitles.ListReindex
|
_Subtitles.Sort()
|
||||||
SubtitlesSelectedIndexesReset()
|
_Subtitles.ListReindex
|
||||||
PostProcessing_OutputSubtitlesFormats_Reset()
|
SubtitlesSelectedIndexesReset()
|
||||||
End If
|
PostProcessing_OutputSubtitlesFormats_Reset()
|
||||||
End With
|
End If
|
||||||
End If
|
End With
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
#End Region
|
#End Region
|
||||||
|
|||||||
Reference in New Issue
Block a user