diff --git a/SCrawler/API/Base/M3U8Base.vb b/SCrawler/API/Base/M3U8Base.vb index 00cf96f..ec393a0 100644 --- a/SCrawler/API/Base/M3U8Base.vb +++ b/SCrawler/API/Base/M3U8Base.vb @@ -34,7 +34,7 @@ Namespace API.Base End Function Friend Shared Function Download(ByVal URLs As List(Of String), ByVal DestinationFile As SFile, Optional ByVal Responser As Responser = Nothing, Optional ByVal Token As CancellationToken = Nothing, Optional ByVal Progress As MyProgress = Nothing, - Optional ByVal UsePreProgress As Boolean = True) As SFile + Optional ByVal UsePreProgress As Boolean = True, Optional ByVal ExistingCache As CacheKeeper = Nothing) As SFile Dim Cache As CacheKeeper = Nothing Using tmpPr As New PreProgress(Progress) Try @@ -42,8 +42,12 @@ Namespace API.Base Dim ConcatFile As SFile = DestinationFile If ConcatFile.Name.IsEmptyString Then ConcatFile.Name = "PlayListFile" ConcatFile.Extension = "mp4" - Cache = New CacheKeeper($"{DestinationFile.PathWithSeparator}_{TempCacheFolderName}\") - Cache.CacheDeleteError = CacheDeletionError(Cache) + If ExistingCache Is Nothing Then + Cache = New CacheKeeper($"{DestinationFile.PathWithSeparator}_{TempCacheFolderName}\") + Cache.CacheDeleteError = CacheDeletionError(Cache) + Else + Cache = ExistingCache + End If Dim cache2 As CacheKeeper = Cache.NewInstance If cache2.RootDirectory.Exists(SFO.Path) Then Dim progressExists As Boolean = Not Progress Is Nothing diff --git a/SCrawler/API/Base/UserDataBase.vb b/SCrawler/API/Base/UserDataBase.vb index 1e856da..f922590 100644 --- a/SCrawler/API/Base/UserDataBase.vb +++ b/SCrawler/API/Base/UserDataBase.vb @@ -751,7 +751,6 @@ BlockNullPicture: End Function Friend Overridable Sub ExchangeOptionsSet(ByVal Obj As Object) Implements IPluginContentProvider.ExchangeOptionsSet End Sub - Private _ExternalCompatibilityToken As CancellationToken #End Region #Region "IIndexable Support" Friend Property Index As Integer = 0 Implements IIndexable.Index @@ -1082,7 +1081,8 @@ BlockNullPicture: Return __DOWNLOAD_IN_PROGRESS End Get End Property - Friend PersonalToken As CancellationToken + Private TokenQueue As CancellationToken + Friend TokenPersonal As CancellationToken Protected Responser As Responser Protected UseResponserClient As Boolean = False Protected UseClientTokens As Boolean = False @@ -1096,7 +1096,7 @@ BlockNullPicture: Private _PictureExists As Boolean Private _EnvirInvokeUserUpdated As Boolean = False Protected Sub EnvirDownloadSet() - PersonalToken = Nothing + TokenPersonal = Nothing ProgressPre.Reset() UpdateDataFiles() _DownloadInProgress = True @@ -1128,7 +1128,7 @@ BlockNullPicture: __DOWNLOAD_IN_PROGRESS = True OnUserDownloadStateChanged(True) Dim Canceled As Boolean = False - _ExternalCompatibilityToken = Token + TokenQueue = Token Try EnvirDownloadSet() If Not Responser Is Nothing Then Responser.Dispose() @@ -1191,6 +1191,7 @@ BlockNullPicture: End Function)) Else DownloadContent(Token) + DownloadedPictures(False) += 1 ThrowIfDisposed() End If @@ -1221,7 +1222,7 @@ BlockNullPicture: End If ThrowIfDisposed() If Not _PictureExists Or _EnvirInvokeUserUpdated Then OnUserUpdated() - Catch oex As OperationCanceledException When Token.IsCancellationRequested Or PersonalToken.IsCancellationRequested + Catch oex As OperationCanceledException When Token.IsCancellationRequested Or TokenPersonal.IsCancellationRequested MyMainLOG = $"{ToStringForLog()}: downloading canceled" Canceled = True Catch exit_ex As ExitException @@ -1288,6 +1289,7 @@ BlockNullPicture: Try Data.DownloadState = UserMediaStates.Tried Progress = Data.Progress + If Not Progress Is Nothing Then Progress.ResetProgressOnMaximumChanges = False If Not Responser Is Nothing Then Responser.Dispose() Responser = New Responser If Not HOST Is Nothing AndAlso HOST.Available(ISiteSettings.Download.SingleObject, True) AndAlso @@ -1722,7 +1724,7 @@ BlockNullPicture: Optional ByVal ThrowEx As Boolean = True) As Integer If TypeOf ex Is ExitException Then Throw ex - ElseIf Not ((TypeOf ex Is OperationCanceledException And (Token.IsCancellationRequested Or PersonalToken.IsCancellationRequested)) Or + ElseIf Not ((TypeOf ex Is OperationCanceledException And (Token.IsCancellationRequested Or TokenPersonal.IsCancellationRequested Or TokenQueue.IsCancellationRequested)) Or (TypeOf ex Is ObjectDisposedException And Disposed)) Then If RDE Then Dim v% = DownloadingException(ex, Message, True, EObj) @@ -2031,13 +2033,14 @@ BlockNullPicture: End Sub ''' Private Overloads Sub ThrowAny() Implements IThrower.ThrowAny - ThrowAny(_ExternalCompatibilityToken) + ThrowAny(TokenQueue) End Sub ''' ''' Friend Overridable Overloads Sub ThrowAny(ByVal Token As CancellationToken) Token.ThrowIfCancellationRequested() - PersonalToken.ThrowIfCancellationRequested() + TokenQueue.ThrowIfCancellationRequested() + TokenPersonal.ThrowIfCancellationRequested() ThrowIfDisposed() End Sub #End Region diff --git a/SCrawler/API/JustForFans/Declarations.vb b/SCrawler/API/JustForFans/Declarations.vb new file mode 100644 index 0000000..c186879 --- /dev/null +++ b/SCrawler/API/JustForFans/Declarations.vb @@ -0,0 +1,33 @@ +' Copyright (C) 2023 Andy https://github.com/AAndyProgram +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY +Imports System.Text.RegularExpressions +Imports PersonalUtilities.Functions.RegularExpressions +Namespace API.JustForFans + Friend Module Declarations + Friend Const NamePhotoLarge As String = "expandable" + Friend Const NamePhotoSmall As String = "galThumb" + Private Const PostDateUrlPattern As String = "\]*?location.href='([^']+)[^\>]*?\>([^\<]+?)\<" + Friend ReadOnly RegexUser As RParams = RParams.DMS("GetStats2\(UserID\)\{\s*var Hash = '([^']+)'[;\s/]*(var Hash = '([^']+)'|)", 1) + Friend ReadOnly RegexVideoBlock As RParams = + RParams.DM("((\
]*?id=""([^""]+)[^\>]*?\>)\s*\
]*?\>[^\<\>]*?\\s*\
)", + 0, RegexReturn.List, RegexOptions.Singleline, RegexOptions.IgnoreCase, EDP.ReturnValue) + Friend ReadOnly Regex_Video As RParams = RParams.DMS("