Migrating YouTube enlarger.
This commit is contained in:
parent
ba2235f83c
commit
338caaa4bf
19
README.md
19
README.md
@ -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
|
||||
@ -34,5 +29,11 @@ ConfigurationOfShortener load.
|
||||
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
|
||||
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>
|
@ -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' }
|
||||
|
22
Shortener/YouTube.class.st
Normal file
22
Shortener/YouTube.class.st
Normal 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.
|
||||
]
|
Loading…
Reference in New Issue
Block a user