Setting the default instance according to best response times and API availability.
This commit is contained in:
parent
9337c46863
commit
4b6ad35ed6
@ -10,12 +10,20 @@ Class {
|
||||
'api',
|
||||
'monitor'
|
||||
],
|
||||
#classInstVars : [
|
||||
'default'
|
||||
],
|
||||
#category : #VideoWeb
|
||||
}
|
||||
|
||||
{ #category : #accessing }
|
||||
Invidious class >> default: anObject [
|
||||
default := anObject
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Invidious class >> defaultInstance [
|
||||
^ self instances select: [ :instance | instance api = true ]
|
||||
^ default ifNil: [ default := self responseTimes first key ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
@ -27,6 +35,11 @@ Invidious class >> instances [
|
||||
Invidious new fromDictionary: instanceDict ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Invidious class >> instancesWithAPIEnabled [
|
||||
^ self instances select: [ :instance | instance api = true ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Invidious class >> rawInstances [
|
||||
^ STON
|
||||
@ -34,6 +47,22 @@ Invidious class >> rawInstances [
|
||||
retrieveContents
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Invidious class >> responseTimes [
|
||||
| responses |
|
||||
responses := Dictionary new.
|
||||
self instancesWithAPIEnabled do: [ :instance | | runTime|
|
||||
runTime := [ ZnClient new
|
||||
beOneShot;
|
||||
url: instance uri;
|
||||
get;
|
||||
response ] timeToRun.
|
||||
responses at: instance put: runTime.
|
||||
].
|
||||
^ (responses associations asSortedCollection: [ :x :y| x value < y value ])
|
||||
collect: [:assoc | assoc ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Invidious >> api [
|
||||
^ api
|
||||
|
Loading…
Reference in New Issue
Block a user