Skip to content

Commit 5b64e55

Browse files
committed
2.0.0.4
Fixed network paths bug Updated classes for new library structures and functions Fixed some typos Fixed minor bugs SitePaths
1 parent 1bc0485 commit 5b64e55

24 files changed

+256
-81
lines changed

Changelog.md

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1+
# 2.0.0.4
2+
3+
**Removed compatibility of program settings with version 1.0.0.4 and lower.**
4+
5+
**If your program version is 1.0.0.4 and lower, it is strongly recommended that you upgrade to release 2.0.0.1 to update the program settings (and run the program). Then update to this release. Otherwise, you will have to configure the program settings again**
6+
7+
**If your program version is 1.0.1.0 or higher, you should not pay attention to this message.**
8+
9+
- Added
10+
- Ability to specify the path to store saved posts
11+
- Fixed
12+
- **Error when specifying network paths**
13+
- Minor bugs
14+
115
# 2.0.0.3
216

317
**Removed compatibility of program settings with version 1.0.0.4 and lower.**
418

5-
**If your program version is 1.0.0.4 and lower, it is strongly recommended that you upgrade to release 2.0.0.2 to update the program settings (and run the program). Then update to this release. Otherwise, you will have to configure the program settings again**
19+
**If your program version is 1.0.0.4 and lower, it is strongly recommended that you upgrade to release 2.0.0.1 to update the program settings (and run the program). Then update to this release. Otherwise, you will have to configure the program settings again**
620

721
**If your program version is 1.0.1.0 or higher, you should not pay attention to this message.**
822

@@ -31,7 +45,7 @@
3145
- Clear information about downloaded profiles of the current session in the "Download info form"
3246
- Increased the number of Instagram posts (from 12 to 50) received per request
3347
- Channels' statistics
34-
- **RedGisf profiles support**
48+
- **RedGifs profiles support**
3549
- Fixed
3650
- The program was showing incorrect information about the total numbers of images and videos downloaded when a Reddit user was created from a channel
3751

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ You can add users by patterns:
8888

8989
Read more about adding users and subreddits [here](https://github.com/AAndyProgram/SCrawler/wiki/Users)
9090

91+
# Guide
92+
9193
**Full guide you can find [here](https://github.com/AAndyProgram/SCrawler/wiki)**
9294

9395
## Using program as just video downloader

SCrawler/API/Base/SiteSettings.vb

+30-14
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,41 @@
99
Imports PersonalUtilities.Tools
1010
Imports PersonalUtilities.Functions.XML
1111
Imports PersonalUtilities.Functions.XML.Base
12+
Imports PersonalUtilities.Functions.RegularExpressions
1213
Namespace API.Base
1314
Friend Class SiteSettings : Implements IDisposable
1415
Friend Const Header_Twitter_Authorization As String = "authorization"
1516
Friend Const Header_Twitter_Token As String = "x-csrf-token"
1617
Friend ReadOnly Site As Sites
1718
Friend ReadOnly Responser As WEB.Response
1819
Private ReadOnly _Path As XMLValue(Of SFile)
19-
Friend Property Path As SFile
20+
Friend Property Path(Optional ByVal SetProp As Boolean = True) As SFile
2021
Get
21-
If _Path.IsEmptyString Then _Path.Value = SFile.GetPath($"{Settings.GlobalPath.Value.PathWithSeparator}{Site}")
22+
If _Path.IsEmptyString Then
23+
Dim tmpPath As SFile = SFile.GetPath($"{Settings.GlobalPath.Value.PathWithSeparator}{Site}")
24+
If SetProp Then _Path.Value = tmpPath Else Return tmpPath
25+
End If
2226
Return _Path.Value
2327
End Get
24-
Set(ByVal NewFile As SFile)
25-
_Path.Value = NewFile
28+
Set(ByVal NewPath As SFile)
29+
_Path.Value = NewPath
30+
End Set
31+
End Property
32+
Private ReadOnly _SavedPostsPath As XMLValue(Of SFile)
33+
Friend Property SavedPostsPath(Optional ByVal GetAny As Boolean = True) As SFile
34+
Get
35+
If Not _SavedPostsPath.Value.IsEmptyString Then
36+
Return _SavedPostsPath.Value
37+
Else
38+
If GetAny Then
39+
Return $"{Path.PathNoSeparator}\!Saved\"
40+
Else
41+
Return Nothing
42+
End If
43+
End If
44+
End Get
45+
Set(ByVal NewPath As SFile)
46+
_SavedPostsPath.Value = NewPath
2647
End Set
2748
End Property
2849
#Region "Instagram"
@@ -122,7 +143,7 @@ Namespace API.Base
122143
End If
123144

124145
Dim n() As String = {SettingsCLS.Name_Node_Sites, Site.ToString}
125-
_Path = New XMLValue(Of SFile)("Path", SFile.GetPath($"{GlobalPath.PathWithSeparator}{Site}"), _XML, n, XMLValue(Of SFile).ToFilePath)
146+
_Path = New XMLValue(Of SFile)("Path",, _XML, n, XMLValue(Of SFile).ToFilePath)
126147
_XML.Remove(Site.ToString)
127148

128149
Temporary = New XMLValue(Of Boolean)
@@ -138,6 +159,7 @@ Namespace API.Base
138159
DownloadVideos.SetDefault(_Vids)
139160

140161
GetUserMediaOnly = New XMLValue(Of Boolean)("GetUserMediaOnly", True, _XML, n)
162+
_SavedPostsPath = New XMLValue(Of SFile)("SavedPostsPath",, _XML, n, XMLValue(Of SFile).ToFilePath)
141163

142164
CreateProp(InstaHashUpdateRequired, Sites.Instagram, "InstaHashUpdateRequired", True, _XML, n)
143165
CreateProp(InstaHash, Sites.Instagram, "InstaHash", String.Empty, _XML, n)
@@ -149,7 +171,7 @@ Namespace API.Base
149171
CreateProp(RequestsWaitTimerTaskCount, Sites.Instagram, "RequestsWaitTimerTaskCount", 1, _XML, n)
150172
CreateProp(SleepTimerOnPostsLimit, Sites.Instagram, "SleepTimerOnPostsLimit", 60000, _XML, n)
151173
If Site = Sites.Instagram Then
152-
InstagramDownloadingErrorDate = New XMLValue(Of Date) With {.ToStringFunction = Function(ss, vv) AConvert(Of String)(vv, Nothing)}
174+
InstagramDownloadingErrorDate = New XMLValue(Of Date) With {.ToStringFunction = Function(ss, vv) AConvert(Of String)(vv, AModes.Var, Nothing)}
153175
InstagramDownloadingErrorDate.SetExtended("InstagramDownloadingErrorDate", Now.AddYears(-10), _XML, n)
154176
Else
155177
InstagramDownloadingErrorDate = New XMLValue(Of Date)
@@ -170,10 +192,7 @@ Namespace API.Base
170192
End Sub
171193
Friend Function GatherInstaHash() As Boolean
172194
Try
173-
Dim rs As New RegexStructure("=" & Chr(34) & "([^" & Chr(34) & "]+?ConsumerLibCommons[^" & Chr(34) & "]+?.js)" & Chr(34), 1) With {
174-
.UseTimeOut = True,
175-
.MatchTimeOutSeconds = 10
176-
}
195+
Dim rs As New RParams("=""([^""]+?ConsumerLibCommons[^""]+?.js)""", Nothing, 1) With {.MatchTimeOut = 10}
177196
Dim r$ = Responser.GetResponse("https://instagram.com",, EDP.ThrowException)
178197
If Not r.IsEmptyString Then
179198
Dim hStr$ = RegexReplace(r, rs)
@@ -182,10 +201,7 @@ Namespace API.Base
182201
hStr = $"https://instagram.com/{hStr}"
183202
r = Responser.GetResponse(hStr,, EDP.ThrowException)
184203
If Not r.IsEmptyString Then
185-
rs = New RegexStructure("generatePaginationActionCreators.+?.profilePosts.byUserId.get.+?queryId:.([\d\w\S]+?)" & Chr(34), 1) With {
186-
.UseTimeOut = True,
187-
.MatchTimeOutSeconds = 10
188-
}
204+
rs = New RParams("generatePaginationActionCreators.+?.profilePosts.byUserId.get.+?queryId:.([\d\w\S]+?)""", Nothing, 1) With {.MatchTimeOut = 10}
189205
Dim h$ = RegexReplace(r, rs)
190206
If Not h.IsEmptyString Then
191207
InstaHash.Value = h

SCrawler/API/Base/UserDataBase.vb

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
' This program is distributed in the hope that it will be useful,
88
' but WITHOUT ANY WARRANTY
99
Imports PersonalUtilities.Functions.XML
10+
Imports PersonalUtilities.Functions.RegularExpressions
1011
Imports PersonalUtilities.Forms.Toolbars
1112
Imports System.IO
1213
Imports System.Net
@@ -470,7 +471,7 @@ BlockNullPicture:
470471
Temporary = x.Value(Name_Temporary).FromXML(Of Boolean)(False)
471472
Favorite = x.Value(Name_Favorite).FromXML(Of Boolean)(False)
472473
CreatedByChannel = x.Value(Name_CreatedByChannel).FromXML(Of Boolean)(False)
473-
SeparateVideoFolder = AConvert(Of Boolean)(x.Value(Name_SeparateVideoFolder), Nothing)
474+
SeparateVideoFolder = AConvert(Of Boolean)(x.Value(Name_SeparateVideoFolder), AModes.Var, Nothing)
474475
ReadyForDownload = x.Value(Name_ReadyForDownload).FromXML(Of Boolean)(True)
475476
DownloadImages = x.Value(Name_DownloadImages).FromXML(Of Boolean)(True)
476477
DownloadVideos = x.Value(Name_DownloadVideos).FromXML(Of Boolean)(True)
@@ -944,7 +945,7 @@ BlockNullPicture:
944945
End Sub
945946
Private Function CheckFile(ByVal f As SFile, ByRef List As IEnumerable(Of SFile)) As SFile
946947
If List.ListExists Then
947-
Dim p As New RegexStructure(".+?\s{0,1}\((\d+)\)|.+",,,,,,, String.Empty, EDP.ReturnValue)
948+
Dim p As RParams = RParams.DMS(".+?\s{0,1}\((\d+)\)|.+", 0, EDP.ReturnValue)
948949
Dim i% = List.Where(Function(ff) CStr(RegexReplace(ff.Name, p)).Trim.ToLower = f.Name.Trim.ToLower).Count
949950
If i > 0 Then f.Name &= $" ({i + 1})"
950951
End If

SCrawler/API/Imgur/Envir.vb

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
' This program is distributed in the hope that it will be useful,
88
' but WITHOUT ANY WARRANTY
99
Imports PersonalUtilities.Functions.XML
10+
Imports PersonalUtilities.Functions.RegularExpressions
1011
Imports PersonalUtilities.Tools.WebDocuments.JSON
1112
Imports System.Net
1213
Imports SCrawler.API.Imgur.Declarations
1314
Imports SCrawler.API.Base
14-
Namespace API.Imgur.Declarations
15-
Friend Module Imgur_Declarations
16-
Friend ReadOnly PostRegex As New RegexStructure("/([\w\d]+?)(|\.[\w]{0,4})\Z", 1)
17-
End Module
18-
End Namespace
1915
Namespace API.Imgur
16+
Namespace Declarations
17+
Friend Module Imgur_Declarations
18+
Friend ReadOnly PostRegex As RParams = RParams.DMS("/([\w\d]+?)(|\.[\w]{0,4})\Z", 1)
19+
End Module
20+
End Namespace
2021
Friend NotInheritable Class Envir
2122
Private Sub New()
2223
End Sub

SCrawler/API/Instagram/Declarations.vb

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
'
77
' This program is distributed in the hope that it will be useful,
88
' but WITHOUT ANY WARRANTY
9+
Imports PersonalUtilities.Functions.RegularExpressions
910
Namespace API.Instagram
1011
Friend Module Declarations
11-
Friend ReadOnly FilesPattern As New RegexStructure(".+?([^/\?]+?\.[\w\d]{3,4})(?=(\?|\Z))",,,, 1,,, String.Empty, EDP.ReturnValue)
12+
Friend ReadOnly FilesPattern As RParams = RParams.DMS(".+?([^/\?]+?\.[\w\d]{3,4})(?=(\?|\Z))", 1, EDP.ReturnValue)
1213
Friend ReadOnly Property DateProvider As New JsonDate
1314
Friend Class JsonDate : Implements ICustomProvider
1415
Friend Function Convert(ByVal Value As Object, ByVal DestinationType As Type, ByVal Provider As IFormatProvider,

SCrawler/API/Instagram/ProfileSaved.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Imports System.Threading
1111
Imports PersonalUtilities.Forms.Toolbars
1212
Namespace API.Instagram
1313
Friend NotInheritable Class ProfileSaved
14-
Friend Shared ReadOnly Property DataPath As SFile = $"{Settings(Sites.Instagram).Path.PathNoSeparator}\!Saved\"
14+
Friend Shared ReadOnly Property DataPath As SFile = Settings(Sites.Instagram).SavedPostsPath
1515
Private Sub New()
1616
End Sub
1717
Friend Shared Sub Download(ByRef Bar As MyProgress, ByVal Token As CancellationToken)

SCrawler/API/Instagram/UserData.vb

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
' but WITHOUT ANY WARRANTY
99
Imports PersonalUtilities.Functions.XML
1010
Imports PersonalUtilities.Functions.Messaging
11+
Imports PersonalUtilities.Functions.RegularExpressions
1112
Imports PersonalUtilities.Tools.WebDocuments.JSON
1213
Imports PersonalUtilities.Forms.Toolbars
1314
Imports SCrawler.API.Base
@@ -414,7 +415,7 @@ Namespace API.Instagram
414415
Friend Shared Function GetVideoInfo(ByVal URL As String) As IEnumerable(Of UserMedia)
415416
Try
416417
If Not URL.IsEmptyString AndAlso URL.Contains("instagram.com") Then
417-
Dim PID$ = RegexReplace(URL, New RegexStructure(".*?instagram.com/p/([_\w\d]+)", 1))
418+
Dim PID$ = RegexReplace(URL, RParams.DMS(".*?instagram.com/p/([_\w\d]+)", 1))
418419
If Not PID.IsEmptyString Then
419420
Using t As New UserData
420421
t.Responser = New PersonalUtilities.Tools.WEB.Response

SCrawler/API/Reddit/Declarations.vb

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
' This program is distributed in the hope that it will be useful,
88
' but WITHOUT ANY WARRANTY
99
Imports PersonalUtilities.Functions.XML.Base
10+
Imports PersonalUtilities.Functions.RegularExpressions
1011
Namespace API.Reddit
1112
Friend Module Declarations
1213
Friend ReadOnly JsonNodesJson() As NodeParams = {New NodeParams("posts", True, True, True, True, 3)}
1314
Friend ReadOnly ChannelJsonNodes() As NodeParams = {New NodeParams("data", True, True, True, True, 1),
1415
New NodeParams("children", True, True, True)}
15-
Friend ReadOnly UrlBasePattern As New RegexStructure("(?<=/)([^/]+?\.[\w]{3,4})(?=(\?|\Z))", True, False)
16-
Friend ReadOnly VideoRegEx As New RegexStructure("http.{0,1}://[^" & Chr(34) & "]+?mp4", True, False)
16+
Friend ReadOnly UrlBasePattern As RParams = RParams.DM("(?<=/)([^/]+?\.[\w]{3,4})(?=(\?|\Z))", 0)
17+
Friend ReadOnly VideoRegEx As RParams = RParams.DM("http.{0,1}://[^" & Chr(34) & "]+?mp4", 0)
1718
Friend ReadOnly DateProvider As New JsonDate
1819
Friend ReadOnly DateProviderChannel As New JsonDateChannel
1920
Private ReadOnly EUR_PROVIDER As New ANumbers(ANumbers.Cultures.EUR)

SCrawler/API/Reddit/M3U8.vb

+13-14
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,25 @@
99
Imports System.Net
1010
Imports SCrawler.API.Reddit.M3U8_Declarations
1111
Imports PersonalUtilities.Tools.WEB
12-
Namespace API.Reddit.M3U8_Declarations
13-
Friend Module M3U8_Declarations
14-
Friend ReadOnly BaseUrlPattern As New RegexStructure("([htps:/]{7,8}.+?/.+?)(?=/)", True, False,,,,,, EDP.ReturnValue)
15-
Friend ReadOnly PlayListRegEx_1 As New RegexStructure("(#EXT-X-STREAM-INF)(.+)(RESOLUTION=)(\d+)(.+?[\r\n]{1,2})(.+?)([\r\n]{1,2})", True, False,,,
16-
RegexReturn.List,, New List(Of String),
17-
New ErrorsDescriber(False, False, True, New List(Of String)))
18-
Friend ReadOnly PlayListRegEx_2 As New RegexStructure("(?<=#EXT-X-BYTERANGE.+?[\r\n]{1,2})(.+)(?=[\r\n]{0,2})", True, False,,, RegexReturn.List,,
19-
New List(Of String),
20-
New ErrorsDescriber(False, False, True, New List(Of String)))
21-
Friend ReadOnly DPED As New ErrorsDescriber(EDP.SendInLog + EDP.ReturnValue)
22-
End Module
23-
End Namespace
12+
Imports PersonalUtilities.Functions.RegularExpressions
2413
Namespace API.Reddit
14+
Namespace M3U8_Declarations
15+
Friend Module M3U8_Declarations
16+
Friend ReadOnly BaseUrlPattern As RParams = RParams.DM("([htps:/]{7,8}.+?/.+?)(?=/)", 0, EDP.ReturnValue)
17+
Friend ReadOnly PlayListRegEx_1 As RParams = RParams.DM("(#EXT-X-STREAM-INF)(.+)(RESOLUTION=)(\d+)(.+?[\r\n]{1,2})(.+?)([\r\n]{1,2})", 0,
18+
RegexReturn.List, EDP.SendInLog, EDP.ReturnValue)
19+
Friend ReadOnly PlayListRegEx_2 As RParams = RParams.DM("(?<=#EXT-X-BYTERANGE.+?[\r\n]{1,2})(.+)(?=[\r\n]{0,2})", 0,
20+
RegexReturn.List, EDP.SendInLog, EDP.ReturnValue)
21+
Friend ReadOnly DPED As New ErrorsDescriber(EDP.SendInLog + EDP.ReturnValue)
22+
End Module
23+
End Namespace
2524
Friend NotInheritable Class M3U8
2625
Private Sub New()
2726
End Sub
2827
Private Structure Resolution : Implements IRegExCreator, IComparable(Of Resolution)
2928
Friend File As String
3029
Friend Resolution As Integer
31-
Friend Function CreateFromArray(ByVal ParamsArray() As String) As IRegExCreator Implements IRegExCreator.CreateFromArray
30+
Friend Function CreateFromArray(ByVal ParamsArray() As String) As Object Implements IRegExCreator.CreateFromArray
3231
If ParamsArray.ArrayExists Then
3332
File = ParamsArray(0)
3433
If ParamsArray.Length > 1 Then Resolution = AConvert(Of Integer)(ParamsArray(1), 0)
@@ -45,7 +44,7 @@ Namespace API.Reddit
4544
Using w As New WebClient
4645
Dim r$ = w.DownloadString(PlayListURL)
4746
If Not r.IsEmptyString Then
48-
Dim l As List(Of Resolution) = RegexFields(Of Resolution)(r, {PlayListRegEx_1}, {6, 4})
47+
Dim l As List(Of Resolution) = FNF.RegexFields(Of Resolution)(r, {PlayListRegEx_1}, {6, 4})
4948
If l.ListExists Then
5049
l.Sort()
5150
Dim pls$ = $"{BaseUrl}/{l.First.File}"

SCrawler/API/Reddit/ProfileSaved.vb

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Imports System.Threading
1111
Imports PersonalUtilities.Forms.Toolbars
1212
Namespace API.Reddit
1313
Friend NotInheritable Class ProfileSaved
14-
Friend Shared ReadOnly Property DataPath As SFile = $"{Settings(Sites.Reddit).Path.PathNoSeparator}\!Saved\"
14+
Friend Shared ReadOnly Property DataPath As SFile = Settings(Sites.Reddit).SavedPostsPath
1515
Private Sub New()
1616
End Sub
1717
Friend Shared Sub Download(ByRef Bar As MyProgress, ByVal Token As CancellationToken)

0 commit comments

Comments
 (0)