2023.9.28.0

API.Mastodon: hide 503 error
API.PornHub: minor fixes
API.RedGifs: fix 'DataGone'
Minor bugs
This commit is contained in:
Andy
2023-09-28 17:38:34 +03:00
parent 77443cedc4
commit f4eb33d8da
5 changed files with 20 additions and 16 deletions

View File

@@ -11,6 +11,6 @@ Namespace Plugin
Overloads Sub Add(ByVal Message As String) Overloads Sub Add(ByVal Message As String)
Overloads Sub Add(ByVal ex As Exception, ByVal Message As String, Overloads Sub Add(ByVal ex As Exception, ByVal Message As String,
Optional ByVal ShowMainMsg As Boolean = False, Optional ByVal ShowErrorMsg As Boolean = False, Optional ByVal ShowMainMsg As Boolean = False, Optional ByVal ShowErrorMsg As Boolean = False,
Optional ByVal SendInLog As Boolean = True) Optional ByVal SendToLog As Boolean = True)
End Interface End Interface
End Namespace End Namespace

View File

@@ -203,17 +203,21 @@ Namespace API.Mastodon
#Region "UpdateServersList" #Region "UpdateServersList"
Private Sub UpdateServersList() Private Sub UpdateServersList()
Try Try
Dim r$ = GetWebString("https://api.joinmastodon.org/servers?language=&category=&region=&ownership=&registrations=",, EDP.ThrowException) Using resp As New Responser With {
If Not r.IsEmptyString Then .ProcessExceptionDecision = Function(rr, obj, e) If(rr.StatusCode = Net.HttpStatusCode.ServiceUnavailable,
Dim j As EContainer = JsonDocument.Parse(r, EDP.ReturnValue) EDP.ReturnValue, EDP.ThrowException)}
If If(j?.Count, 0) > 0 Then Dim r$ = resp.GetResponse("https://api.joinmastodon.org/servers?language=&category=&region=&ownership=&registrations=")
Domains.Domains.ListAddList(j.Select(Function(e) e.Value("domain")), LAP.NotContainsOnly, EDP.ReturnValue) If Not r.IsEmptyString Then
Domains.Domains.Sort() Dim j As EContainer = JsonDocument.Parse(r, EDP.ReturnValue)
Domains.Save() If If(j?.Count, 0) > 0 Then
j.Dispose() Domains.Domains.ListAddList(j.Select(Function(e) e.Value("domain")), LAP.NotContainsOnly, EDP.ReturnValue)
Domains.Domains.Sort()
Domains.Save()
j.Dispose()
End If
DomainsLastUpdateDate.Value = Now
End If End If
End If End Using
DomainsLastUpdateDate.Value = Now
Catch ex As Exception Catch ex As Exception
ErrorsDescriber.Execute(EDP.SendToLog, ex, "[API.Mastodon.SiteSettings.UpdateServersList]") ErrorsDescriber.Execute(EDP.SendToLog, ex, "[API.Mastodon.SiteSettings.UpdateServersList]")
End Try End Try

View File

@@ -896,8 +896,8 @@ Namespace API.PornHub
If Not script.IsEmptyString Then If Not script.IsEmptyString Then
Using j As EContainer = JsonDocument.Parse(script) Using j As EContainer = JsonDocument.Parse(script)
If j.ListExists Then If j.ListExists Then
Dim s As List(Of Sizes) = j.Select(Function(jj) New Sizes(jj.Value("quality"), jj.Value("videoUrl"))).ToList Dim s As List(Of Sizes) = j.Select(Function(jj) New Sizes(jj.Value("quality"), jj.Value("videoUrl"))).ListWithRemove(Function(d) d.HasError Or d.Data.IsEmptyString)
If s.ListExists Then s.Sort() : result = s(0).Data If s.ListExists Then s.Sort() : result = s(0).Data : s.Clear()
End If End If
End Using End Using
End If End If

View File

@@ -249,7 +249,7 @@ Namespace API.RedGifs
Optional ByVal EObj As Object = Nothing) As Integer Optional ByVal EObj As Object = Nothing) As Integer
Dim s As WebExceptionStatus = Responser.Status Dim s As WebExceptionStatus = Responser.Status
Dim sc As HttpStatusCode = Responser.StatusCode Dim sc As HttpStatusCode = Responser.StatusCode
If sc = HttpStatusCode.NotFound Or s = DataGone Then If sc = HttpStatusCode.NotFound Or s = DataGone Or sc = DataGone Then
UserExists = False UserExists = False
ElseIf sc = HttpStatusCode.Unauthorized Then ElseIf sc = HttpStatusCode.Unauthorized Then
MyMainLOG = $"RedGifs credentials have expired [{CInt(sc)}]: {ToStringForLog()}" MyMainLOG = $"RedGifs credentials have expired [{CInt(sc)}]: {ToStringForLog()}"

View File

@@ -13,8 +13,8 @@ Namespace Plugin.Hosts
End Sub End Sub
Friend Sub Add(ByVal ex As Exception, ByVal Message As String, Friend Sub Add(ByVal ex As Exception, ByVal Message As String,
Optional ByVal ShowMainMsg As Boolean = False, Optional ByVal ShowErrorMsg As Boolean = False, Optional ByVal ShowMainMsg As Boolean = False, Optional ByVal ShowErrorMsg As Boolean = False,
Optional ByVal SendInLog As Boolean = True) Implements ILogProvider.Add Optional ByVal SendToLog As Boolean = True) Implements ILogProvider.Add
ErrorsDescriber.Execute(New ErrorsDescriber(ShowMainMsg, ShowErrorMsg, SendInLog), ex, Message) ErrorsDescriber.Execute(New ErrorsDescriber(ShowMainMsg, ShowErrorMsg, SendToLog), ex, Message)
End Sub End Sub
End Class End Class
End Namespace End Namespace