@@ -33,6 +33,7 @@ Namespace API.Base
33
33
# End Region
34
34
# Region "XML Declarations"
35
35
Private Const Name_Site As String = "Site"
36
+ Private Const Name_IsChannel As String = "IsChannel"
36
37
Private Const Name_UserName As String = "UserName"
37
38
Private Const Name_FriendlyName As String = "FriendlyName"
38
39
Private Const Name_UserID As String = "UserID"
@@ -131,7 +132,7 @@ Namespace API.Base
131
132
Protected Function GetNullPicture( ByVal MaxHeigh As XML.Base.XMLValue( Of Integer )) As Bitmap
132
133
Return New Bitmap( CInt (DivideWithZeroChecking(MaxHeigh.Value, 100 ) * 75 ), MaxHeigh.Value)
133
134
End Function
134
- Private Function GetPicture( Optional ByVal ReturnNullImageOnNothing As Boolean = True ) As Image
135
+ Protected Function GetPicture( Optional ByVal ReturnNullImageOnNothing As Boolean = True ) As Image
135
136
Dim f As SFile = Nothing
136
137
Dim p As UserImage = Nothing
137
138
Dim DelPath As Boolean = True
@@ -234,7 +235,7 @@ BlockNullPicture:
234
235
# Region "Downloading params"
235
236
Protected _DataLoaded As Boolean = False
236
237
Protected _DataParsed As Boolean = False
237
- Friend Property ReadyForDownload As Boolean = True Implements IUserData.ReadyForDownload
238
+ Friend Overridable Property ReadyForDownload As Boolean = True Implements IUserData.ReadyForDownload
238
239
Friend Property DownloadImages As Boolean = True Implements IUserData.DownloadImages
239
240
Friend Property DownloadVideos As Boolean = True Implements IUserData.DownloadVideos
240
241
# End Region
@@ -409,7 +410,12 @@ BlockNullPicture:
409
410
''' <exception cref="ArgumentOutOfRangeException"></exception>
410
411
Friend Overloads Shared Function GetInstance( ByVal u As UserInfo, Optional ByVal _LoadUserInformation As Boolean = True ) As IUserData
411
412
Select Case u.Site
412
- Case Sites.Reddit : Return New Reddit.UserData(u, _LoadUserInformation)
413
+ Case Sites.Reddit
414
+ If u.IsChannel Then
415
+ Return New Reddit.Channel(u, _LoadUserInformation)
416
+ Else
417
+ Return New Reddit.UserData(u, _LoadUserInformation)
418
+ End If
413
419
Case Sites.Twitter : Return New Twitter.UserData(u, _LoadUserInformation)
414
420
Case Else : Throw New ArgumentOutOfRangeException( "Site" , $"Site [{u.Site}] information does not recognized by loader" )
415
421
End Select
@@ -560,7 +566,7 @@ BlockNullPicture:
560
566
Try
561
567
Dim URL$ = String .Empty
562
568
Select Case Site
563
- Case Sites.Reddit : URL = $"https://www.reddit.com/user/{Name}/"
569
+ Case Sites.Reddit : URL = $"https://www.reddit.com/{IIf(IsChannel, " r ", " user ")} /{Name}/"
564
570
Case Sites.Twitter : URL = $"https://twitter.com/{Name}"
565
571
Case Else : MsgBoxE( $"Site [{Site}] opening does not implemented" , MsgBoxStyle.Exclamation)
566
572
End Select
@@ -597,7 +603,7 @@ BlockNullPicture:
597
603
If _TempMediaList.Count > 0 Then
598
604
If Not DownloadImages Then _TempMediaList.RemoveAll( Function (m) m.Type = UserMedia.Types.GIF Or m.Type = UserMedia.Types.Picture)
599
605
If Not DownloadVideos Then _TempMediaList.RemoveAll( Function (m) m.Type = UserMedia.Types.Video Or
600
- m.Type = UserMedia.Types.VideoPre Or m.Type = UserMedia.Types.m3u8)
606
+ m.Type = UserMedia.Types.VideoPre Or m.Type = UserMedia.Types.m3u8)
601
607
End If
602
608
603
609
ReparseVideo(Token)
@@ -640,7 +646,7 @@ BlockNullPicture:
640
646
DownloadTopCount = Nothing
641
647
End Try
642
648
End Sub
643
- Private Sub UpdateDataFiles()
649
+ Protected Sub UpdateDataFiles()
644
650
If Not User.File.IsEmptyString Then
645
651
MyFileData = User.File
646
652
MyFileData.Name &= "_Data"
@@ -680,32 +686,38 @@ BlockNullPicture:
680
686
# End Region
681
687
# Region "Delete, Move, Merge"
682
688
Friend Overridable Function Delete() As Integer Implements IUserData.Delete
689
+ Return DeleteF( Me )
690
+ End Function
691
+ Friend Function DeleteF( ByVal Instance As IUserData) As Integer
683
692
Dim f As SFile = SFile.GetPath(MyFile.CutPath.Path)
684
693
If f.Exists(SFO.Path, False ) AndAlso f.Delete(SFO.Path, False , False ) Then
685
694
ImageHandler( Me , False )
686
695
Settings.UsersList.Remove(User)
687
696
Settings.UpdateUsersList()
688
- Settings.Users.Remove( Me )
689
- Downloader.UserRemove( Me )
697
+ Settings.Users.Remove(Instance )
698
+ Downloader.UserRemove(Instance )
690
699
Dispose( True )
691
700
Return 1
692
701
Else
693
702
Return 0
694
703
End If
695
704
End Function
696
- Friend Overridable Function MoveFiles( ByVal __CollectionName As String , ByVal _MergeData As Boolean ) As Boolean Implements IUserData.MoveFiles
705
+ Friend Overridable Function MoveFiles( ByVal __CollectionName As String ) As Boolean Implements IUserData.MoveFiles
706
+ Return MoveFilesF( Me , __CollectionName)
707
+ End Function
708
+ Friend Function MoveFilesF( ByRef Instance As IUserData, ByVal __CollectionName As String ) As Boolean
697
709
Dim UserBefore As UserInfo = User
698
710
Dim Removed As Boolean = True
699
711
Dim _TurnBack As Boolean = False
700
712
Try
701
713
Dim f As SFile
702
714
If IncludedInCollection Then
703
- Settings.Users.Add( Me )
715
+ Settings.Users.Add(Instance )
704
716
Removed = False
705
717
User.CollectionName = String .Empty
706
718
User.IncludedInCollection = False
707
719
Else
708
- Settings.Users.Remove( Me )
720
+ Settings.Users.Remove(Instance )
709
721
Removed = True
710
722
User.CollectionName = __CollectionName
711
723
User.IncludedInCollection = True
@@ -720,7 +732,7 @@ BlockNullPicture:
720
732
"Destination directory is not empty!" }, MsgBoxStyle.Exclamation,,, { "Delete" , "Cancel" }) = 1 Then
721
733
MsgBoxE( "Operation canceled" , MsgBoxStyle.Exclamation)
722
734
User = UserBefore
723
- If Removed Then Settings.Users.Add( Me ) Else Settings.Users.Remove( Me )
735
+ If Removed Then Settings.Users.Add(Instance ) Else Settings.Users.Remove(Instance )
724
736
_TurnBack = False
725
737
Return False
726
738
End If
@@ -736,7 +748,7 @@ BlockNullPicture:
736
748
ErrorsDescriber.Execute(EDP.LogMessageValue, ex, "Files moving error" )
737
749
User = UserBefore
738
750
If _TurnBack Then
739
- If Removed Then Settings.Users.Add( Me ) Else Settings.Users.Remove( Me )
751
+ If Removed Then Settings.Users.Add(Instance ) Else Settings.Users.Remove(Instance )
740
752
End If
741
753
Return False
742
754
End Try
@@ -783,6 +795,8 @@ BlockNullPicture:
783
795
End If
784
796
UpdateUserInformation()
785
797
End If
798
+ Catch ioex As InvalidOperationException When ioex.HelpLink = 1
799
+ MsgBoxE(ioex.Message, vbCritical)
786
800
Catch ex As Exception
787
801
LogError(ex, "[UserDataBase.MergeData]" )
788
802
End Try
@@ -872,15 +886,23 @@ BlockNullPicture:
872
886
Return OutValue
873
887
End Function
874
888
Friend Overridable Function CompareTo( ByVal Obj As Object ) As Integer Implements IComparable.CompareTo
875
- Return CompareTo( DirectCast (Obj, UserDataBase))
889
+ If TypeOf Obj Is Reddit.Channel Then
890
+ Return CompareTo( DirectCast ( DirectCast (Obj, Reddit.Channel).Instance, UserDataBase))
891
+ Else
892
+ Return CompareTo( DirectCast (Obj, UserDataBase))
893
+ End If
876
894
End Function
877
895
# End Region
878
896
# Region "IEquatable Support"
879
897
Friend Overridable Overloads Function Equals ( ByVal Other As UserDataBase) As Boolean Implements IEquatable( Of UserDataBase).Equals
880
898
Return Site = Other.Site And Name = Other.Name
881
899
End Function
882
900
Public Overrides Function Equals ( ByVal Obj As Object ) As Boolean
883
- Return Equals ( DirectCast (Obj, UserDataBase))
901
+ If TypeOf Obj Is Reddit.Channel Then
902
+ Return Equals ( DirectCast ( DirectCast (Obj, Reddit.Channel).Instance, UserDataBase))
903
+ Else
904
+ Return Equals ( DirectCast (Obj, UserDataBase))
905
+ End If
884
906
End Function
885
907
# End Region
886
908
# Region "IDisposable Support"
@@ -966,7 +988,7 @@ BlockNullPicture:
966
988
''' 3 - Collection splitted
967
989
''' </summary>
968
990
Function Delete() As Integer
969
- Function MoveFiles( ByVal CollectionName As String , ByVal MergeData As Boolean ) As Boolean
991
+ Function MoveFiles( ByVal CollectionName As String ) As Boolean
970
992
Sub OpenFolder()
971
993
ReadOnly Property Self As IUserData
972
994
Property DownloadTopCount As Integer ?
0 commit comments