@@ -10,6 +10,7 @@ Imports PersonalUtilities.Functions.XML
10
10
Imports PersonalUtilities.Tools.WebDocuments.JSON
11
11
Imports System.Net
12
12
Imports SCrawler.API.Imgur.Declarations
13
+ Imports SCrawler.API.Base
13
14
Namespace API.Imgur.Declarations
14
15
Friend Module Imgur_Declarations
15
16
Friend ReadOnly PostRegex As New RegexStructure( "/([\w\d]+?)(|\.[\w]{0,4})\Z" , 1 )
@@ -19,7 +20,7 @@ Namespace API.Imgur
19
20
Friend NotInheritable Class Envir
20
21
Private Sub New ()
21
22
End Sub
22
- Friend Shared Function GetGallery( ByVal URL As String ) As List( Of String )
23
+ Friend Shared Function GetGallery( ByVal URL As String , Optional ByVal e As ErrorsDescriber = Nothing ) As List( Of String )
23
24
Try
24
25
If Not Settings.ImgurClientID.IsEmptyString And Not URL.IsEmptyString Then
25
26
Dim __url$ = RegexReplace(URL, PostRegex)
@@ -45,10 +46,11 @@ Namespace API.Imgur
45
46
End If
46
47
Return Nothing
47
48
Catch ex As Exception
48
- Return ErrorsDescriber.Execute(EDP.ReturnValue + EDP.SendInLog, ex, $"[API.Imgur.Envir.GetGallery({URL})]" , Nothing )
49
+ If Not e.Exists Then e = New ErrorsDescriber(EDP.ReturnValue + EDP.SendInLog)
50
+ Return ErrorsDescriber.Execute(e, ex, $"[API.Imgur.Envir.GetGallery({URL})]" , Nothing )
49
51
End Try
50
52
End Function
51
- Friend Shared Function GetImage( ByVal URL As String ) As String
53
+ Friend Shared Function GetImage( ByVal URL As String , Optional ByVal e As ErrorsDescriber = Nothing ) As String
52
54
Try
53
55
If Not Settings.ImgurClientID.IsEmptyString And Not URL.IsEmptyString Then
54
56
Dim __url$ = RegexReplace(URL, PostRegex)
@@ -62,7 +64,23 @@ Namespace API.Imgur
62
64
End If
63
65
Return String .Empty
64
66
Catch ex As Exception
65
- Return ErrorsDescriber.Execute(EDP.ReturnValue + EDP.SendInLog, ex, $"[API.Imgur.Envir.GetImage({URL})]" , String .Empty)
67
+ If Not e.Exists Then e = New ErrorsDescriber(EDP.ReturnValue + EDP.SendInLog)
68
+ Return ErrorsDescriber.Execute(e, ex, $"[API.Imgur.Envir.GetImage({URL})]" , String .Empty)
69
+ End Try
70
+ End Function
71
+ Friend Shared Function GetVideoInfo( ByVal URL As String ) As IEnumerable( Of UserMedia)
72
+ Try
73
+ If Not URL.IsEmptyString AndAlso URL.ToLower.Contains( "imgur" ) AndAlso Not Settings.ImgurClientID.IsEmptyString Then
74
+ Dim img$ = GetImage(URL, EDP.ReturnValue)
75
+ If Not img.IsEmptyString Then
76
+ Return { New UserMedia(img)}
77
+ Else
78
+ Return GetGallery(URL, EDP.ReturnValue).ListIfNothing.Select( Function (u) New UserMedia(u))
79
+ End If
80
+ End If
81
+ Return Nothing
82
+ Catch ex As Exception
83
+ Return ErrorsDescriber.Execute(EDP.ShowMainMsg + EDP.SendInLog, ex, "Imgur standalone downloader: fetch media error" )
66
84
End Try
67
85
End Function
68
86
End Class
0 commit comments