From 26db0e3e24357968c2c35d608c2693dff7cd858d Mon Sep 17 00:00:00 2001 From: Andy <88590076+AAndyProgram@users.noreply.github.com> Date: Thu, 1 Aug 2024 20:41:51 +0300 Subject: [PATCH] 2024.8.1.0 Feed: add the ability to set PostUrl for data when moving a file and/or adding to a feed TDownloader: add 'PostUrl' property to 'UserMediaD' --- Changelog.md | 9 +++++ SCrawler/Download/Feed/DownloadFeedForm.vb | 13 +++++- SCrawler/Download/Feed/FeedMedia.vb | 2 + SCrawler/Download/Feed/FeedSpecial.vb | 6 ++- SCrawler/Download/TDownloader.vb | 47 +++++++++++++++++++++- SCrawler/My Project/AssemblyInfo.vb | 4 +- 6 files changed, 75 insertions(+), 6 deletions(-) diff --git a/Changelog.md b/Changelog.md index 3ab6b70..7aa0c19 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,12 @@ +# 2024.8.1.0 + +*2024-08-01* + +- Added + - Minor improvements +- Updated + - yt-dlp up to version **2024.08.01** + # 2024.7.24.0 *2024-07-24* diff --git a/SCrawler/Download/Feed/DownloadFeedForm.vb b/SCrawler/Download/Feed/DownloadFeedForm.vb index 11e1e13..d1df807 100644 --- a/SCrawler/Download/Feed/DownloadFeedForm.vb +++ b/SCrawler/Download/Feed/DownloadFeedForm.vb @@ -574,6 +574,7 @@ Namespace DownloadObjects Dim sesFilesReplaced As Boolean = False Dim filesReplace As New List(Of KeyValuePair(Of SFile, SFile)) Dim updateFileLocations As Boolean = Settings.FeedMoveCopyUpdateFileLocationOnMove + Dim postUrl$ Dim result As Boolean = False If FeedMediaData Is Nothing Then @@ -678,7 +679,11 @@ Namespace DownloadObjects mm_data = mm.Data mm_data.File = df __isSavedPosts = mm.IsSavedPosts And moveOptions.ReplaceUserProfile_Profile Is Nothing - mm = New UserMediaD(mm_data, If(moveOptions.ReplaceUserProfile_Profile, mm.User), mm.Session, mm.Date) With {.IsSavedPosts = __isSavedPosts} + postUrl = mm.PostUrl(True) + mm = New UserMediaD(mm_data, If(moveOptions.ReplaceUserProfile_Profile, mm.User), mm.Session, mm.Date) With { + .IsSavedPosts = __isSavedPosts, + .PostUrl = postUrl + } If __isSavedPosts Then mm.UserInfo = __user Downloader.Files(indx) = mm downloaderFilesUpdated = True @@ -709,7 +714,11 @@ Namespace DownloadObjects mm_data = mm.Data mm_data.File = df __isSavedPosts = mm.IsSavedPosts And moveOptions.ReplaceUserProfile_Profile Is Nothing - mm = New UserMediaD(mm_data, If(moveOptions.ReplaceUserProfile_Profile, mm.User), mm.Session, mm.Date) With {.IsSavedPosts = __isSavedPosts} + postUrl = mm.PostUrl(True) + mm = New UserMediaD(mm_data, If(moveOptions.ReplaceUserProfile_Profile, mm.User), mm.Session, mm.Date) With { + .IsSavedPosts = __isSavedPosts, + .PostUrl = postUrl + } If __isSavedPosts Then mm.UserInfo = __user sessionData(indx) = mm sesFilesReplaced = True diff --git a/SCrawler/Download/Feed/FeedMedia.vb b/SCrawler/Download/Feed/FeedMedia.vb index 2eedd5c..16b59d1 100644 --- a/SCrawler/Download/Feed/FeedMedia.vb +++ b/SCrawler/Download/Feed/FeedMedia.vb @@ -455,6 +455,8 @@ Namespace DownloadObjects Dim url$ = String.Empty If IsSubscription Then url = Post.URL_BASE + ElseIf Not Media.PostUrl.IsEmptyString Then + url = Media.PostUrl Else If Not UserKey.IsEmptyString And Not Post.Post.ID.IsEmptyString Then Dim u As IUserData diff --git a/SCrawler/Download/Feed/FeedSpecial.vb b/SCrawler/Download/Feed/FeedSpecial.vb index 0b2da08..84f758a 100644 --- a/SCrawler/Download/Feed/FeedSpecial.vb +++ b/SCrawler/Download/Feed/FeedSpecial.vb @@ -195,6 +195,7 @@ Namespace DownloadObjects #Region "Add" Friend Overloads Function Add(ByVal Item As UserMediaD, Optional ByVal AutoSave As Boolean = True) As Boolean If Not Items.Contains(Item) Then + Item.PostUrl = Item.PostUrl(True) Items.Add(Item) If AutoSave Then Save() Return True @@ -242,6 +243,7 @@ Namespace DownloadObjects Dim m As UserMedia Dim f As SFile = Nothing Dim ff As SFile + Dim postUrl$ = String.Empty Dim user As IUserData Dim processRemove As Boolean Dim userArr As New List(Of IUserData) @@ -254,7 +256,8 @@ Namespace DownloadObjects m = d.Data m.File = ff d = New UserMediaD(m, If(replaceUser, d.User), d.Session, d.Date) With { - .IsSavedPosts = If(replaceUser Is Nothing, d.IsSavedPosts, DirectCast(replaceUser, UserDataBase).IsSavedPosts) + .IsSavedPosts = If(replaceUser Is Nothing, d.IsSavedPosts, DirectCast(replaceUser, UserDataBase).IsSavedPosts), + .PostUrl = postUrl } Items(i) = d ri += 1 @@ -268,6 +271,7 @@ Namespace DownloadObjects For i = Count - 1 To 0 Step -1 If p.Invoke(Items(i)) Then d = Items(i) + postUrl = d.PostUrl(True) f = Nothing ff = Nothing processRemove = True diff --git a/SCrawler/Download/TDownloader.vb b/SCrawler/Download/TDownloader.vb index 8650781..ac2151e 100644 --- a/SCrawler/Download/TDownloader.vb +++ b/SCrawler/Download/TDownloader.vb @@ -36,6 +36,7 @@ Namespace DownloadObjects Private Const Name_Session As String = "Session" Private Const Name_File As String = "File" Private Const Name_IsSavedPosts As String = "IsSavedPosts" + Private Const Name_PostUrl As String = "PostUrl" #End Region Friend ReadOnly User As IUserData Friend ReadOnly Data As UserMedia @@ -43,6 +44,48 @@ Namespace DownloadObjects Friend ReadOnly [Date] As Date Friend Session As Integer Friend IsSavedPosts As Boolean + Private _PostUrl As String + Friend Property PostUrl(Optional ByVal Generate As Boolean = False) As String + Get + Try + If Not _PostUrl.IsEmptyString Then + Return _PostUrl + ElseIf Generate Then + Dim url$ = String.Empty + With UserInfo + If Not .Plugin.IfNullOrEmpty(.Site).IsEmptyString And Not .Name.IsEmptyString And Not Data.Post.ID.IsEmptyString Then + Dim u As IUserData + If IsSavedPosts Then + If Not .Plugin.IsEmptyString Then + Dim host As SettingsHostCollection = Settings(.Plugin) + If Not host Is Nothing Then + u = host.Default.GetInstance(Download.SavedPosts, UserInfo, False, False) + If Not u Is Nothing AndAlso Not u.HOST Is Nothing Then + With DirectCast(u, UserDataBase) + .IsSavedPosts = True + .HostStatic = True + End With + Try : url = u.HOST.Source.GetUserPostUrl(u, Data) : Catch : End Try + u.Dispose() + End If + End If + End If + Else + u = Settings.GetUser(UserInfo) + If Not u Is Nothing Then url = UserDataBase.GetPostUrl(u, Data) + End If + End If + End With + Return url + End If + Catch + End Try + Return String.Empty + End Get + Set(ByVal _PostUrl As String) + Me._PostUrl = _PostUrl + End Set + End Property Friend Sub New(ByVal Data As UserMedia, ByVal User As IUserData, ByVal Session As Integer) Me.Data = Data Me.User = User @@ -78,6 +121,7 @@ Namespace DownloadObjects Data = New UserMedia(e(Name_Media), User) [Date] = AConvert(Of Date)(e.Value(Name_Date), DateTimeDefaultProvider, Now) Session = e.Value(Name_Session).FromXML(Of Integer)(0) + _PostUrl = e.Value(Name_PostUrl) Dim f As SFile = e.Value(Name_File) If f.Exists Then Data.File = f End If @@ -106,7 +150,8 @@ Namespace DownloadObjects New EContainer(Name_Date, AConvert(Of String)([Date], DateTimeDefaultProvider, String.Empty)), New EContainer(Name_Session, Session), New EContainer(Name_File, Data.File), - New EContainer(Name_IsSavedPosts, IsSavedPosts.BoolToInteger)}, + New EContainer(Name_IsSavedPosts, IsSavedPosts.BoolToInteger), + New EContainer(Name_PostUrl, _PostUrl)}, If(IsSavedPosts, UserInfo.ToEContainer, If(Not User Is Nothing, DirectCast(User, UserDataBase).User.ToEContainer, Nothing)), LAP.IgnoreICopier) End Function End Structure diff --git a/SCrawler/My Project/AssemblyInfo.vb b/SCrawler/My Project/AssemblyInfo.vb index cff3bdd..55b0b5d 100644 --- a/SCrawler/My Project/AssemblyInfo.vb +++ b/SCrawler/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + +