Migrating YouTube enlarger.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2022-12-26 17:25:14 -05:00
parent ba2235f83c
commit 338caaa4bf
3 changed files with 33 additions and 10 deletions

View File

@ -4,17 +4,12 @@ This is an small wrapper around the [ethical shortener](https://is.gd/ethics.php
## Installation
Run this two steps in a playground:
First install ExoRepo and then run this in a playground:
```smalltalk
"Start by loading the configuration of Shortener"
Gofer new
url: 'http://smalltalkhub.com/mc/Offray/Shortener/main';
package: 'ConfigurationOfShortener';
load.
"After that load Shortener"
ConfigurationOfShortener load.
ExoRepo new
repository: 'https://code.sustrato.red/Offray/Shortener';
load.
```
## Usage
@ -35,4 +30,10 @@ ConfigurationOfShortener load.
For example, by running the previous example the alias 'pharo' has been taken for all future
short urls and can not be used again (you will need to pick a new short url alias).
You can also enlarge a link from YouTube using:
`YouTube enlargeLink: 'https://youtu.be/ggSyF1SVFr4'`
which produces `https://www.youtube.com/watch?v=ggSyF1SVFr4`.
Migrated from: <http://static.smalltalkhub.com/Offray/Shortener/index.html>

View File

@ -10,7 +10,7 @@ I use the public API as described in https://is.gd/apishorteningreference.php#re
Class {
#name : #Shortener,
#superclass : #Object,
#category : #Shortener
#category : #'Shortener-Model'
}
{ #category : #'as yet unclassified' }

View File

@ -0,0 +1,22 @@
Class {
#name : #YouTube,
#superclass : #Object,
#category : #'Shortener-Model'
}
{ #category : #'as yet unclassified' }
YouTube class >> enlargeLink: shortLinkString [
| videoId videoLink 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.
]