@@ -10,6 +10,7 @@ Imports PersonalUtilities.Functions.XML
1010Imports PersonalUtilities.Tools.WebDocuments.JSON
1111Imports System.Net
1212Imports SCrawler.API.Imgur.Declarations
13+ Imports SCrawler.API.Base
1314Namespace API.Imgur.Declarations
1415 Friend Module Imgur_Declarations
1516 Friend ReadOnly PostRegex As New RegexStructure( "/([\w\d]+?)(|\.[\w]{0,4})\Z" , 1 )
@@ -19,7 +20,7 @@ Namespace API.Imgur
1920 Friend NotInheritable Class Envir
2021 Private Sub New ()
2122 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 )
2324 Try
2425 If Not Settings.ImgurClientID.IsEmptyString And Not URL.IsEmptyString Then
2526 Dim __url$ = RegexReplace(URL, PostRegex)
@@ -45,10 +46,11 @@ Namespace API.Imgur
4546 End If
4647 Return Nothing
4748 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 )
4951 End Try
5052 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
5254 Try
5355 If Not Settings.ImgurClientID.IsEmptyString And Not URL.IsEmptyString Then
5456 Dim __url$ = RegexReplace(URL, PostRegex)
@@ -62,7 +64,23 @@ Namespace API.Imgur
6264 End If
6365 Return String .Empty
6466 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" )
6684 End Try
6785 End Function
6886 End Class
0 commit comments