Implementing WebVideo

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-01-07 13:01:14 -05:00
parent b0cb9ac5ae
commit 10717232c2
3 changed files with 124 additions and 1 deletions

View File

@ -16,5 +16,5 @@ BaselineOfVideoWeb >> baseline: spec [
{ #category : #accessing } { #category : #accessing }
BaselineOfVideoWeb >> semanticVersion [ BaselineOfVideoWeb >> semanticVersion [
^ '0.1.0' ^ '0.2.0'
] ]

View File

@ -149,3 +149,12 @@ Invidious >> uri [
Invidious >> uri: urlString [ Invidious >> uri: urlString [
uri := urlString asUrl 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
]

View File

@ -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
]