VideoWeb/app/VideoWeb/WebVideo.class.st

135 lines
2.5 KiB
Smalltalk

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 >> defaultThumbnailLink [
^ (self videoThumbnails
detect: [ :thumbnail | (thumbnail at: 'quality') = 'high' ]) at: 'url'
]
{ #category : #accessing }
WebVideo >> description [
^ description
]
{ #category : #accessing }
WebVideo >> description: anObject [
description := anObject
]
{ #category : #accessing }
WebVideo >> duration [
^ self lengthSeconds asInteger asDuration asString
"This is a new method"
]
{ #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' ifAbsentPut: [ nil ]).
]
{ #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 duration,' | ', self author, ' )'
]
{ #category : #accessing }
WebVideo >> thumbnail [
^ SkiaImage
fromForm: (Form
fromBase64String: self defaultThumbnailLink asUrl retrieveContents base64Encoded)
]
{ #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
]