From 10717232c2c74a9ab1adcaa6e322c1b8d1bd1201 Mon Sep 17 00:00:00 2001 From: Offray Luna Date: Sat, 7 Jan 2023 13:01:14 -0500 Subject: [PATCH] Implementing WebVideo --- .../BaselineOfVideoWeb.class.st | 2 +- app/VideoWeb/Invidious.class.st | 9 ++ app/VideoWeb/WebVideo.class.st | 114 ++++++++++++++++++ 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 app/VideoWeb/WebVideo.class.st diff --git a/app/BaselineOfVideoWeb/BaselineOfVideoWeb.class.st b/app/BaselineOfVideoWeb/BaselineOfVideoWeb.class.st index bd67e0d..aeab32f 100644 --- a/app/BaselineOfVideoWeb/BaselineOfVideoWeb.class.st +++ b/app/BaselineOfVideoWeb/BaselineOfVideoWeb.class.st @@ -16,5 +16,5 @@ BaselineOfVideoWeb >> baseline: spec [ { #category : #accessing } BaselineOfVideoWeb >> semanticVersion [ - ^ '0.1.0' + ^ '0.2.0' ] diff --git a/app/VideoWeb/Invidious.class.st b/app/VideoWeb/Invidious.class.st index 4c9e2e2..6bcaa15 100644 --- a/app/VideoWeb/Invidious.class.st +++ b/app/VideoWeb/Invidious.class.st @@ -149,3 +149,12 @@ Invidious >> uri [ Invidious >> uri: urlString [ uri := urlString asUrl ] + +{ #category : #accessing } +Invidious >> video: videoId [ + | dataUrl queryFields dataDict | + queryFields := 'videoId,title,description,author,authorId,authorUrl,likeCount,lengthSeconds,videoThumbnails'. + dataUrl := (self uri asString, 'api/v1/videos/', videoId, '?fields=', queryFields, '&pretty=1') asUrl. + dataDict := STONJSON fromString: dataUrl retrieveContents. + ^ WebVideo new fromDictionary: dataDict +] diff --git a/app/VideoWeb/WebVideo.class.st b/app/VideoWeb/WebVideo.class.st new file mode 100644 index 0000000..3e383b2 --- /dev/null +++ b/app/VideoWeb/WebVideo.class.st @@ -0,0 +1,114 @@ +Class { + #name : #WebVideo, + #superclass : #Object, + #instVars : [ + 'videoId', + 'author', + 'title', + 'lengthSeconds', + 'description', + 'authorId', + 'videoThumbnails', + 'likeCount' + ], + #category : #VideoWeb +} + +{ #category : #accessing } +WebVideo >> author [ + ^ author +] + +{ #category : #accessing } +WebVideo >> author: anObject [ + author := anObject +] + +{ #category : #accessing } +WebVideo >> authorId [ + ^ authorId +] + +{ #category : #accessing } +WebVideo >> authorId: anObject [ + authorId := anObject +] + +{ #category : #accessing } +WebVideo >> description [ + ^ description +] + +{ #category : #accessing } +WebVideo >> description: anObject [ + description := anObject +] + +{ #category : #accessing } +WebVideo >> fromDictionary: aDictionary [ + ^ self author: (aDictionary at: 'author'); + description: (aDictionary at: 'description'); + videoId: (aDictionary at: 'videoId'); + title: (aDictionary at: 'title'); + authorId: (aDictionary at: 'authorId'); + lengthSeconds: (aDictionary at: 'lengthSeconds'); + videoThumbnails: (aDictionary at: 'videoThumbnails'); + likeCount: (aDictionary at: 'likeCount'). +] + +{ #category : #accessing } +WebVideo >> lengthSeconds [ + ^ lengthSeconds +] + +{ #category : #accessing } +WebVideo >> lengthSeconds: anObject [ + lengthSeconds := anObject +] + +{ #category : #accessing } +WebVideo >> likeCount [ + ^ likeCount +] + +{ #category : #accessing } +WebVideo >> likeCount: anObject [ + likeCount := anObject +] + +{ #category : #accessing } +WebVideo >> printOn: aStream [ + super printOn: aStream. + aStream + nextPutAll: '( ', self videoId, ' | ', self title, ' | ', self author, ' )' +] + +{ #category : #accessing } +WebVideo >> title [ + ^ title +] + +{ #category : #accessing } +WebVideo >> title: anObject [ + title := anObject +] + +{ #category : #accessing } +WebVideo >> videoId [ + ^ videoId +] + +{ #category : #accessing } +WebVideo >> videoId: anObject [ + videoId := anObject +] + +{ #category : #accessing } +WebVideo >> videoThumbnails [ + ^ videoThumbnails +] + +{ #category : #accessing } +WebVideo >> videoThumbnails: anObject [ + videoThumbnails := anObject +]