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 ## Installation
Run this two steps in a playground: First install ExoRepo and then run this in a playground:
```smalltalk ```smalltalk
"Start by loading the configuration of Shortener" ExoRepo new
Gofer new repository: 'https://code.sustrato.red/Offray/Shortener';
url: 'http://smalltalkhub.com/mc/Offray/Shortener/main'; load.
package: 'ConfigurationOfShortener';
load.
"After that load Shortener"
ConfigurationOfShortener load.
``` ```
## Usage ## Usage
@ -34,5 +29,11 @@ ConfigurationOfShortener load.
or will raise an error once a short url have been taken. or will raise an error once a short url have been taken.
For example, by running the previous example the alias 'pharo' has been taken for all future 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). 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> 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 { Class {
#name : #Shortener, #name : #Shortener,
#superclass : #Object, #superclass : #Object,
#category : #Shortener #category : #'Shortener-Model'
} }
{ #category : #'as yet unclassified' } { #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.
]