23 lines
550 B
Smalltalk
23 lines
550 B
Smalltalk
Class {
|
|
#name : #YouTube,
|
|
#superclass : #Object,
|
|
#category : #'Shortener-Model'
|
|
}
|
|
|
|
{ #category : #operation }
|
|
YouTube class >> enlargeLink: shortLinkString [
|
|
| videoId shortLinkHost |
|
|
|
|
shortLinkHost := shortLinkString asZnUrl host.
|
|
(shortLinkHost = 'www.youtube.com') ifTrue: [ ^ shortLinkHost ].
|
|
(shortLinkHost = 'youtu.be') ifFalse: [ ^ self ].
|
|
|
|
videoId := (ZnUrl fromString: shortLinkString) lastPathSegment.
|
|
^ ZnUrl new
|
|
scheme: #https;
|
|
host: 'www.youtube.com';
|
|
addPathSegment: 'watch';
|
|
queryAt: 'v' put: videoId;
|
|
yourself.
|
|
]
|