Skip to content

Commit 67c4b25

Browse files
committed
1.0.0.4
Add full channel support, make ready for download prop available for collections and multiusers Fixed imgur pics compatibility Updated abstract classes and functions for channels compatibility
1 parent 70e73c7 commit 67c4b25

16 files changed

+583
-170
lines changed

Changelog.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 1.0.0.4
2+
3+
- Added
4+
- Full channels support (you can now add channel (subreddit) for standard download)
5+
- ```Ready for download``` now available for collections and can be changed for multiple user
6+
- Fixed
7+
- Images hosted on Imgur won't download
8+
19
# 1.0.0.3
210

311
- Fixed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Enjoying the tool? Considering adding to my coffee fund :)
77
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/andyprogram)
88

99
# What can program do:
10-
- Download pictures and videos from users' profiles:
10+
- Download pictures and videos from users' profiles and subreddits:
1111
- Reddit images;
1212
- Reddit galleries of images;
1313
- Redgifs hosted videos (https://www.redgifs.com/);
@@ -47,10 +47,13 @@ Just add user profile and press ```Start downloading``` button.
4747
Users can be added by patterns:
4848
- https://twitter.com/SomeUserName
4949
- https://reddit.com/user/SomeUserName
50+
- https://reddit.com/r/SomeSubredditName
5051
- u/SomeUserName
52+
- r/SomeSubredditName
5153
- SomeUserName (in this case you must to choose user site)
54+
- SomeSubredditName
5255

53-
More about users adding [here](https://github.com/AAndyProgram/SCrawler/wiki/Users)
56+
More about users and subreddits adding [here](https://github.com/AAndyProgram/SCrawler/wiki/Users)
5457

5558
**Full guide you can find [here](https://github.com/AAndyProgram/SCrawler/wiki)**
5659

SCrawler/API/Base/UserDataBase.vb

+38-16
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Namespace API.Base
3333
#End Region
3434
#Region "XML Declarations"
3535
Private Const Name_Site As String = "Site"
36+
Private Const Name_IsChannel As String = "IsChannel"
3637
Private Const Name_UserName As String = "UserName"
3738
Private Const Name_FriendlyName As String = "FriendlyName"
3839
Private Const Name_UserID As String = "UserID"
@@ -131,7 +132,7 @@ Namespace API.Base
131132
Protected Function GetNullPicture(ByVal MaxHeigh As XML.Base.XMLValue(Of Integer)) As Bitmap
132133
Return New Bitmap(CInt(DivideWithZeroChecking(MaxHeigh.Value, 100) * 75), MaxHeigh.Value)
133134
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
135136
Dim f As SFile = Nothing
136137
Dim p As UserImage = Nothing
137138
Dim DelPath As Boolean = True
@@ -234,7 +235,7 @@ BlockNullPicture:
234235
#Region "Downloading params"
235236
Protected _DataLoaded As Boolean = False
236237
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
238239
Friend Property DownloadImages As Boolean = True Implements IUserData.DownloadImages
239240
Friend Property DownloadVideos As Boolean = True Implements IUserData.DownloadVideos
240241
#End Region
@@ -409,7 +410,12 @@ BlockNullPicture:
409410
''' <exception cref="ArgumentOutOfRangeException"></exception>
410411
Friend Overloads Shared Function GetInstance(ByVal u As UserInfo, Optional ByVal _LoadUserInformation As Boolean = True) As IUserData
411412
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
413419
Case Sites.Twitter : Return New Twitter.UserData(u, _LoadUserInformation)
414420
Case Else : Throw New ArgumentOutOfRangeException("Site", $"Site [{u.Site}] information does not recognized by loader")
415421
End Select
@@ -560,7 +566,7 @@ BlockNullPicture:
560566
Try
561567
Dim URL$ = String.Empty
562568
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}/"
564570
Case Sites.Twitter : URL = $"https://twitter.com/{Name}"
565571
Case Else : MsgBoxE($"Site [{Site}] opening does not implemented", MsgBoxStyle.Exclamation)
566572
End Select
@@ -597,7 +603,7 @@ BlockNullPicture:
597603
If _TempMediaList.Count > 0 Then
598604
If Not DownloadImages Then _TempMediaList.RemoveAll(Function(m) m.Type = UserMedia.Types.GIF Or m.Type = UserMedia.Types.Picture)
599605
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)
601607
End If
602608

603609
ReparseVideo(Token)
@@ -640,7 +646,7 @@ BlockNullPicture:
640646
DownloadTopCount = Nothing
641647
End Try
642648
End Sub
643-
Private Sub UpdateDataFiles()
649+
Protected Sub UpdateDataFiles()
644650
If Not User.File.IsEmptyString Then
645651
MyFileData = User.File
646652
MyFileData.Name &= "_Data"
@@ -680,32 +686,38 @@ BlockNullPicture:
680686
#End Region
681687
#Region "Delete, Move, Merge"
682688
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
683692
Dim f As SFile = SFile.GetPath(MyFile.CutPath.Path)
684693
If f.Exists(SFO.Path, False) AndAlso f.Delete(SFO.Path, False, False) Then
685694
ImageHandler(Me, False)
686695
Settings.UsersList.Remove(User)
687696
Settings.UpdateUsersList()
688-
Settings.Users.Remove(Me)
689-
Downloader.UserRemove(Me)
697+
Settings.Users.Remove(Instance)
698+
Downloader.UserRemove(Instance)
690699
Dispose(True)
691700
Return 1
692701
Else
693702
Return 0
694703
End If
695704
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
697709
Dim UserBefore As UserInfo = User
698710
Dim Removed As Boolean = True
699711
Dim _TurnBack As Boolean = False
700712
Try
701713
Dim f As SFile
702714
If IncludedInCollection Then
703-
Settings.Users.Add(Me)
715+
Settings.Users.Add(Instance)
704716
Removed = False
705717
User.CollectionName = String.Empty
706718
User.IncludedInCollection = False
707719
Else
708-
Settings.Users.Remove(Me)
720+
Settings.Users.Remove(Instance)
709721
Removed = True
710722
User.CollectionName = __CollectionName
711723
User.IncludedInCollection = True
@@ -720,7 +732,7 @@ BlockNullPicture:
720732
"Destination directory is not empty!"}, MsgBoxStyle.Exclamation,,, {"Delete", "Cancel"}) = 1 Then
721733
MsgBoxE("Operation canceled", MsgBoxStyle.Exclamation)
722734
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)
724736
_TurnBack = False
725737
Return False
726738
End If
@@ -736,7 +748,7 @@ BlockNullPicture:
736748
ErrorsDescriber.Execute(EDP.LogMessageValue, ex, "Files moving error")
737749
User = UserBefore
738750
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)
740752
End If
741753
Return False
742754
End Try
@@ -783,6 +795,8 @@ BlockNullPicture:
783795
End If
784796
UpdateUserInformation()
785797
End If
798+
Catch ioex As InvalidOperationException When ioex.HelpLink = 1
799+
MsgBoxE(ioex.Message, vbCritical)
786800
Catch ex As Exception
787801
LogError(ex, "[UserDataBase.MergeData]")
788802
End Try
@@ -872,15 +886,23 @@ BlockNullPicture:
872886
Return OutValue
873887
End Function
874888
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
876894
End Function
877895
#End Region
878896
#Region "IEquatable Support"
879897
Friend Overridable Overloads Function Equals(ByVal Other As UserDataBase) As Boolean Implements IEquatable(Of UserDataBase).Equals
880898
Return Site = Other.Site And Name = Other.Name
881899
End Function
882900
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
884906
End Function
885907
#End Region
886908
#Region "IDisposable Support"
@@ -966,7 +988,7 @@ BlockNullPicture:
966988
''' 3 - Collection splitted
967989
''' </summary>
968990
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
970992
Sub OpenFolder()
971993
ReadOnly Property Self As IUserData
972994
Property DownloadTopCount As Integer?

0 commit comments

Comments
 (0)