Skip to content

Commit 5f2c447

Browse files
committed
1.0.1.0
Extend settings, fix minor bugs, add some functions
1 parent adc563e commit 5f2c447

17 files changed

+949
-369
lines changed

Changelog.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# 1.0.1.0
2+
3+
- Added
4+
- Extended site settings
5+
- Non-existend users will be marked in red
6+
- Suspended users' profiles will be marked in yellow
7+
- Automatically disable 'Ready for download' if user does not exist.
8+
- Ability to disable MD5 check when downloading regular (added to the main window) channels
9+
- Ability to create a user from a channel with the default option 'Ready to download' (setting in the 'Settings')
10+
- Ability to change default 'Temporary' parameter on create a user from a channel (setting in the 'Settings')
11+
- Advanced defaults for each site (download images, download videos and temporary)
12+
- By checking the 'Temporary' checkbox in the user creation form, the 'Ready for download' checkbox became unchecked
13+
- Automatically disable 'Ready for download' if profile does not exists or has been deleted
14+
- Change
15+
- Removed extended twitter invalid credentials error and replaced with a simple line in the log
16+
- Redesigned settings form
17+
- Fixed
18+
- In some cases, the image of the channel post is not copied to the user's folder
19+
- Users in the main window are not refreshed if new users are added by a list that includes banned and/or unrecognized users.
20+
- Minor bugs
21+
122
# 1.0.0.4
223

324
- Added

SCrawler/API/Base/SiteSettings.vb

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ Namespace API.Base
6060
End If
6161
Responser.SaveSettings()
6262
End If
63-
_Path = New XMLValue(Of SFile)("Path", SFile.GetPath($"{GlobalPath.PathWithSeparator}{Site}"), _XML, {Site.ToString}, XMLValue(Of SFile).ToFilePath)
63+
_Path = New XMLValue(Of SFile)("Path", SFile.GetPath($"{GlobalPath.PathWithSeparator}{Site}"),
64+
_XML, {SettingsCLS.Name_Node_Sites, Site.ToString}, XMLValue(Of SFile).ToFilePath)
65+
_Path.ReplaceByValue("Path", {Site.ToString})
66+
_XML.Remove(Site.ToString)
6467
End Sub
6568
Friend Sub Update()
6669
Responser.SaveSettings()

SCrawler/API/Base/UserDataBase.vb

+28-9
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Imports UState = SCrawler.API.Base.UserMedia.States
1313
Namespace API.Base
1414
Friend MustInherit Class UserDataBase : Implements IUserData
1515
Friend Const UserFileAppender As String = "User"
16-
Friend Event OnPictureUpdated As IUserData.OnPictureUpdatedEventHandler Implements IUserData.OnPictureUpdated
17-
Protected Sub Raise_OnPictureUpdated()
18-
RaiseEvent OnPictureUpdated(Me)
16+
Friend Event OnUserUpdated As IUserData.OnUserUpdatedEventHandler Implements IUserData.OnUserUpdated
17+
Protected Sub Raise_OnUserUpdated()
18+
RaiseEvent OnUserUpdated(Me)
1919
End Sub
2020
#Region "Collection buttons"
2121
Friend WithEvents BTT_CONTEXT_DOWN As ToolStripMenuItem
@@ -43,6 +43,8 @@ Namespace API.Base
4343
Private Const Name_Site As String = "Site"
4444
Private Const Name_IsChannel As String = "IsChannel"
4545
Private Const Name_UserName As String = "UserName"
46+
Private Const Name_UserExists As String = "UserExists"
47+
Private Const Name_UserSuspended As String = "UserSuspended"
4648
Private Const Name_FriendlyName As String = "FriendlyName"
4749
Private Const Name_UserID As String = "UserID"
4850
Private Const Name_Description As String = "Description"
@@ -76,6 +78,10 @@ Namespace API.Base
7678
#Region "Declarations"
7779
Friend MustOverride Property Site As Sites Implements IContentProvider.Site
7880
Friend User As UserInfo
81+
Protected Const NonExistendUserHelp As String = "404"
82+
Protected Const SuspendedUserHelp As String = "403"
83+
Friend Overridable Property UserExists As Boolean = True Implements IUserData.Exists
84+
Friend Overridable Property UserSuspended As Boolean = False Implements IUserData.Suspended
7985
Friend Overridable Property Name As String Implements IContentProvider.Name
8086
Get
8187
Return User.Name
@@ -436,10 +442,11 @@ BlockNullPicture:
436442
If MyFile.Exists Then
437443
FileExists = True
438444
Using x As New XmlFile(MyFile) With {.XmlReadOnly = True}
439-
x.DefaultsLoading(False)
440445
User.Site = Site
441446
Site = x.Value(Name_Site).FromXML(Of Integer)(0)
442447
User.Name = x.Value(Name_UserName)
448+
UserExists = x.Value(Name_UserExists).FromXML(Of Boolean)(True)
449+
UserSuspended = x.Value(Name_UserSuspended).FromXML(Of Boolean)(False)
443450
ID = x.Value(Name_UserID)
444451
FriendlyName = x.Value(Name_FriendlyName)
445452
UserDescription = x.Value(Name_Description)
@@ -470,6 +477,8 @@ BlockNullPicture:
470477
Using x As New XmlFile With {.Name = "User"}
471478
x.Add(Name_Site, CInt(Site))
472479
x.Add(Name_UserName, User.Name)
480+
x.Add(Name_UserExists, UserExists.BoolToInteger)
481+
x.Add(Name_UserSuspended, UserSuspended.BoolToInteger)
473482
x.Add(Name_UserID, ID)
474483
x.Add(Name_FriendlyName, FriendlyName)
475484
x.Add(Name_Description, UserDescription)
@@ -508,9 +517,8 @@ BlockNullPicture:
508517
Private Overloads Sub LoadContentInformation(ByRef _CLIST As List(Of UserMedia), ByVal f As SFile)
509518
Try
510519
If Not f.Exists Then Exit Sub
511-
Using x As New XmlFile(f, ProtectionLevels.All, False) With {.XmlReadOnly = True, .AllowSameNames = True}
520+
Using x As New XmlFile(f, Protector.Modes.All, False) With {.XmlReadOnly = True, .AllowSameNames = True}
512521
x.LoadData()
513-
x.DefaultsLoading(False)
514522
If x.Count > 0 Then
515523
Dim fs$ = MyFile.CutPath.PathWithSeparator
516524
Dim gfn As Func(Of String, String) = Function(ByVal Input As String) As String
@@ -589,11 +597,17 @@ BlockNullPicture:
589597
#End Region
590598
#Region "Download functions and options"
591599
Friend Overridable Property DownloadTopCount As Integer? = Nothing Implements IUserData.DownloadTopCount
600+
Protected Responser As PersonalUtilities.Tools.WEB.Response
592601
Friend Overridable Sub DownloadData(ByVal Token As CancellationToken) Implements IContentProvider.DownloadData
593602
Dim Canceled As Boolean = False
594603
Try
595604
UpdateDataFiles()
605+
If Not Responser Is Nothing Then Responser.Dispose()
606+
Responser = New PersonalUtilities.Tools.WEB.Response
607+
Responser.Copy(Settings.Site(Site).Responser)
596608
Dim UpPic As Boolean = Settings.ViewModeIsPicture AndAlso GetPicture(False) Is Nothing
609+
Dim sEnvir() As Boolean = {UserExists, UserSuspended}
610+
Dim EnvirChanged As Func(Of Boolean) = Function() Not sEnvir(0) = UserExists Or Not sEnvir(1) = UserSuspended
597611
_DownloadedPicturesSession = 0
598612
_DownloadedVideosSession = 0
599613
_TempMediaList.Clear()
@@ -623,7 +637,7 @@ BlockNullPicture:
623637
_ContentList.ListAddList(_ContentNew.Where(Function(c) c.State = UState.Downloaded), LNC)
624638
_CountPictures = _ContentList.LongCount(Function(c) c.Type = UserMedia.Types.Picture)
625639
_CountVideo = _ContentList.LongCount(Function(c) c.Type = UserMedia.Types.Video)
626-
If DownloadedPictures + DownloadedVideos > 0 Then
640+
If DownloadedPictures + DownloadedVideos > 0 Or EnvirChanged.Invoke Then
627641
If __SaveData Then
628642
LastUpdated = Now
629643
If Labels.Contains(LabelsKeeper.NoParsedUser) Then Labels.Remove(LabelsKeeper.NoParsedUser)
@@ -634,12 +648,13 @@ BlockNullPicture:
634648
_ContentList.Clear()
635649
CreatedByChannel = False
636650
End If
651+
If Not UserExists Then ReadyForDownload = False
637652
UpdateUserInformation()
638653
End If
639654
ThrowIfDisposed()
640655
_DownloadedPicturesTotal += _DownloadedPicturesSession
641656
_DownloadedVideosTotal += _DownloadedVideosSession
642-
If UpPic Then Raise_OnPictureUpdated()
657+
If UpPic Or EnvirChanged.Invoke Then Raise_OnUserUpdated()
643658
Catch oex As OperationCanceledException When Token.IsCancellationRequested
644659
MyMainLOG = $"{Site} - {Name}: downloading canceled"
645660
Canceled = True
@@ -649,6 +664,7 @@ BlockNullPicture:
649664
LogError(ex, "downloading data error")
650665
HasError = True
651666
Finally
667+
If Not Responser Is Nothing Then Responser.Dispose() : Responser = Nothing
652668
If Not Canceled Then _DataParsed = True ': LastUpdated = Now
653669
_ContentNew.Clear()
654670
DownloadTopCount = Nothing
@@ -927,6 +943,7 @@ BlockNullPicture:
927943
_ContentNew.Clear()
928944
_TempMediaList.Clear()
929945
_TempPostsList.Clear()
946+
If Not Responser Is Nothing Then Responser.Dispose()
930947
If Not BTT_CONTEXT_DOWN Is Nothing Then BTT_CONTEXT_DOWN.Dispose()
931948
If Not BTT_CONTEXT_EDIT Is Nothing Then BTT_CONTEXT_EDIT.Dispose()
932949
If Not BTT_CONTEXT_DELETE Is Nothing Then BTT_CONTEXT_DELETE.Dispose()
@@ -959,7 +976,7 @@ BlockNullPicture:
959976
Sub DownloadData(ByVal Token As CancellationToken)
960977
End Interface
961978
Friend Interface IUserData : Inherits IContentProvider, IComparable(Of UserDataBase), IComparable, IEquatable(Of UserDataBase), IDisposable
962-
Event OnPictureUpdated(ByVal User As IUserData)
979+
Event OnUserUpdated(ByVal User As IUserData)
963980
Property ParseUserMediaOnly As Boolean
964981
#Region "Images"
965982
Function GetPicture() As Image
@@ -972,6 +989,8 @@ BlockNullPicture:
972989
ReadOnly Property Labels As List(Of String)
973990
#End Region
974991
ReadOnly Property IsChannel As Boolean
992+
Property Exists As Boolean
993+
Property Suspended As Boolean
975994
Property ReadyForDownload As Boolean
976995
Property [File] As SFile
977996
Property FileExists As Boolean

SCrawler/API/Reddit/Channel.vb

+16-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@ Namespace API.Reddit
2222
#End Region
2323
Friend Const DefaultDownloadLimitCount As Integer = 1000
2424
#Region "IUserData Support"
25-
Private Event OnPictureUpdated(User As IUserData) Implements IUserData.OnPictureUpdated
25+
Private Event OnUserUpdated As IUserData.OnUserUpdatedEventHandler Implements IUserData.OnUserUpdated
2626
Friend Property Instance As IUserData
2727
Private Property IUserData_ParseUserMediaOnly As Boolean = False Implements IUserData.ParseUserMediaOnly
28+
Private Property IUserData_Exists As Boolean Implements IUserData.Exists
29+
Get
30+
Return Instance.Exists
31+
End Get
32+
Set(ByVal e As Boolean)
33+
End Set
34+
End Property
35+
Private Property IUserData_Suspended As Boolean Implements IUserData.Suspended
36+
Get
37+
Return Instance.Suspended
38+
End Get
39+
Set(ByVal s As Boolean)
40+
End Set
41+
End Property
2842
Private ReadOnly Property IUserData_IsCollection As Boolean Implements IUserData.IsCollection
2943
Get
3044
Return Instance.IsCollection
@@ -504,9 +518,8 @@ Namespace API.Reddit
504518
End Function
505519
Friend Overloads Function LoadData(ByVal f As SFile, ByVal PartialLoad As Boolean, Optional ByVal e As ErrorsDescriber = Nothing) As Boolean
506520
If f.Exists Then
507-
Using x As New XmlFile(f, ProtectionLevels.All, False) With {.XmlReadOnly = True, .AllowSameNames = True}
521+
Using x As New XmlFile(f, Protector.Modes.All, False) With {.XmlReadOnly = True, .AllowSameNames = True}
508522
x.LoadData()
509-
x.DefaultsLoading(False)
510523
If x.Count > 0 Then
511524
Dim XMLDateProvider As New ADateTime(ADateTime.Formats.BaseDateTime)
512525
Name = x.Value(Name_Name)
@@ -527,7 +540,6 @@ Namespace API.Reddit
527540
Friend Overloads Function Save(Optional ByVal f As SFile = Nothing, Optional ByVal e As ErrorsDescriber = Nothing) As Boolean Implements ILoaderSaver.Save
528541
Dim XMLDateProvider As New ADateTime(ADateTime.Formats.BaseDateTime)
529542
Using x As New XmlFile With {.AllowSameNames = True, .Name = "Channel"}
530-
x.DefaultsLoading(False)
531543
x.Add(Name_Name, Name)
532544
x.Add(Name_ID, ID)
533545
If Posts.Count > 0 Or PostsLatest.Count > 0 Then

SCrawler/API/Reddit/UserData.vb

+34-9
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Namespace API.Reddit
6262
#Region "Initializers"
6363
''' <summary>Video downloader initializer</summary>
6464
Private Sub New()
65+
ChannelPostsNames = New List(Of String)
66+
_ExistsUsersNames = New List(Of String)
6567
End Sub
6668
''' <summary>Default initializer</summary>
6769
Friend Sub New(ByVal u As UserInfo, Optional ByVal _LoadUserInformation As Boolean = True, Optional ByVal InvokeImageHandler As Boolean = True)
@@ -75,6 +77,9 @@ Namespace API.Reddit
7577
#Region "Download Overrides"
7678
Friend Overrides Sub DownloadData(ByVal Token As CancellationToken)
7779
If IsChannel AndAlso Not ChannelInfo.IsRegularChannel Then
80+
If Not Responser Is Nothing Then Responser.Dispose()
81+
Responser = New PersonalUtilities.Tools.WEB.Response
82+
Responser.Copy(Settings.Site(Sites.Reddit).Responser)
7883
ChannelPostsNames.ListAddList(ChannelInfo.PostsAll.Select(Function(p) p.ID), LNC)
7984
If SkipExistsUsers Then _ExistsUsersNames.ListAddList(Settings.UsersList.Select(Function(p) p.Name), LNC)
8085
DownloadDataF(Token)
@@ -201,8 +206,14 @@ Namespace API.Reddit
201206
Catch oex As OperationCanceledException When Token.IsCancellationRequested
202207
Catch dex As ObjectDisposedException When Disposed
203208
Catch ex As Exception
204-
LogError(ex, $"data downloading error [{URL}]")
205-
HasError = True
209+
If ex.HelpLink = NonExistendUserHelp Then
210+
UserExists = False
211+
ElseIf ex.HelpLink = SuspendedUserHelp Then
212+
UserSuspended = True
213+
Else
214+
LogError(ex, $"data downloading error [{URL}]")
215+
HasError = True
216+
End If
206217
End Try
207218
End Sub
208219
Private Sub DownloadDataChannel(ByVal POST As String, ByVal Token As CancellationToken)
@@ -283,8 +294,14 @@ Namespace API.Reddit
283294
Catch oex As OperationCanceledException When Token.IsCancellationRequested
284295
Catch dex As ObjectDisposedException When Disposed
285296
Catch ex As Exception
286-
LogError(ex, $"channel data downloading error [{URL}]")
287-
HasError = True
297+
If ex.HelpLink = NonExistendUserHelp Then
298+
UserExists = False
299+
ElseIf ex.HelpLink = SuspendedUserHelp Then
300+
UserSuspended = True
301+
Else
302+
LogError(ex, $"channel data downloading error [{URL}]")
303+
HasError = True
304+
End If
288305
End Try
289306
End Sub
290307
#End Region
@@ -384,6 +401,8 @@ Namespace API.Reddit
384401
If Not URL.IsEmptyString AndAlso URL.Contains("redgifs") Then
385402
Using r As New UserData
386403
r._TempMediaList.Add(MediaFromData(UTypes.VideoPre, URL, String.Empty, String.Empty,, False))
404+
r.Responser = New PersonalUtilities.Tools.WEB.Response
405+
r.Responser.Copy(Settings.Site(Sites.Reddit).Responser)
387406
r.ReparseVideo(Nothing)
388407
If r._TempMediaList.ListExists Then Return r._TempMediaList(0)
389408
End Using
@@ -442,6 +461,7 @@ Namespace API.Reddit
442461
Dim cached As Boolean = IsChannel And SaveToCache
443462
Dim vsf As Boolean = SeparateVideoFolderF
444463
Dim ImgFormat As Imaging.ImageFormat
464+
Dim UseMD5 As Boolean = Not IsChannel Or (Not cached And Settings.ChannelsRegularCheckMD5)
445465
Dim bDP As New ErrorsDescriber(EDP.None)
446466
Dim MD5BS As Func(Of String, UTypes,
447467
SFile, Boolean, String) = Function(ByVal __URL As String, ByVal __MT As UTypes,
@@ -474,7 +494,7 @@ Namespace API.Reddit
474494
End If
475495
f.Separator = "\"
476496
m = String.Empty
477-
If (v.Type = UTypes.Picture Or v.Type = UTypes.GIF) And Not cached Then
497+
If (v.Type = UTypes.Picture Or v.Type = UTypes.GIF) And UseMD5 Then
478498
m = MD5BS(v.URL, v.Type, f, False)
479499
If m.IsEmptyString AndAlso Not v.URL_BASE.IsEmptyString AndAlso Not v.URL_BASE = v.URL Then
480500
m = MD5BS(v.URL_BASE, v.Type, f, True)
@@ -483,7 +503,7 @@ Namespace API.Reddit
483503
End If
484504

485505
If (Not m.IsEmptyString AndAlso Not HashList.Contains(m)) Or Not (v.Type = UTypes.Picture Or
486-
v.Type = UTypes.GIF) Or cached Then
506+
v.Type = UTypes.GIF) Or Not UseMD5 Then
487507
If Not cached Then HashList.Add(m)
488508
v.MD5 = m
489509
f.Path = MyDir
@@ -536,15 +556,20 @@ Namespace API.Reddit
536556
End Sub
537557
Protected Function GetSiteResponse(ByVal URL As String, Optional ByVal e As ErrorsDescriber = Nothing) As String
538558
Try
539-
Return Settings.Site(Sites.Reddit).Responser.GetResponse(URL,, EDP.ThrowException)
559+
Return Responser.GetResponse(URL,, EDP.ThrowException)
540560
Catch ex As Exception
541561
HasError = True
542562
Dim OptText$ = String.Empty
543563
If Not e.Exists Then
544564
Dim ee As EDP = EDP.SendInLog
545-
If Settings.Site(Sites.Reddit).Responser.StatusCode = HttpStatusCode.NotFound Then
546-
ee += EDP.ThrowException
565+
If Responser.StatusCode = HttpStatusCode.NotFound Then
566+
ee = EDP.ThrowException
547567
OptText = ": USER NOT FOUND"
568+
ex.HelpLink = NonExistendUserHelp
569+
ElseIf Responser.StatusCode = HttpStatusCode.Forbidden Then
570+
ee = EDP.ThrowException
571+
OptText = ": USER PROFILE SUSPENDED"
572+
ex.HelpLink = SuspendedUserHelp
548573
Else
549574
ee += EDP.ReturnValue
550575
End If

0 commit comments

Comments
 (0)