From 510fdb03e487abb6b200f5f3d47c6983418dbcf0 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Wed, 28 Dec 2022 15:59:08 -0500 Subject: [PATCH] Starting package. --- app/VideoWeb/Invidious.class.st | 69 +++++++++++++++++++++++++++++++++ app/VideoWeb/package.st | 1 + 2 files changed, 70 insertions(+) create mode 100644 app/VideoWeb/Invidious.class.st create mode 100644 app/VideoWeb/package.st diff --git a/app/VideoWeb/Invidious.class.st b/app/VideoWeb/Invidious.class.st new file mode 100644 index 0000000..787ccc6 --- /dev/null +++ b/app/VideoWeb/Invidious.class.st @@ -0,0 +1,69 @@ +" +I model the API for the [Invidious](https://invidious.io/) open source front-end for YouTube. +" +Class { + #name : #Invidious, + #superclass : #Object, + #instVars : [ + 'uri', + 'region', + 'api' + ], + #category : #VideoWeb +} + +{ #category : #accessing } +Invidious class >> instances [ + + ^ self rawInstances collect: [ :instanceData | + | instanceDict | + instanceDict := instanceData second. + Invidious new fromDictionary: instanceDict ] +] + +{ #category : #accessing } +Invidious class >> rawInstances [ + ^ STON + fromString: 'https://api.invidious.io/instances.json?sort_by=type,users' asUrl + retrieveContents +] + +{ #category : #accessing } +Invidious >> api: booleanValue [ + (booleanValue = 'true') + ifTrue: [ api := true ] ifFalse: [ api := false ] +] + +{ #category : #accessing } +Invidious >> fromDictionary: aDictionary [ + self + uri: (aDictionary at: 'uri'); + region: (aDictionary at: 'region'); + api: (aDictionary at: 'api') +] + +{ #category : #accessing } +Invidious >> printOn: aStream [ + super printOn: aStream. + ^ aStream nextPutAll: ' ( ', self uri asString, ' | ', self region, ' ) ' +] + +{ #category : #accessing } +Invidious >> region [ + ^ region +] + +{ #category : #accessing } +Invidious >> region: countryISOCode [ + region := countryISOCode +] + +{ #category : #accessing } +Invidious >> uri [ + ^ uri +] + +{ #category : #accessing } +Invidious >> uri: urlString [ + uri := urlString asUrl +] diff --git a/app/VideoWeb/package.st b/app/VideoWeb/package.st new file mode 100644 index 0000000..17ea8b5 --- /dev/null +++ b/app/VideoWeb/package.st @@ -0,0 +1 @@ +Package { #name : #VideoWeb }