-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from radiovisual/cleanup
Misc Cleanup
- Loading branch information
Showing
33 changed files
with
10,713 additions
and
10,383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CI | ||
on: | ||
- push | ||
- pull_request | ||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: | ||
- 16 | ||
- 14 | ||
- 12 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm install | ||
- run: npm test | ||
- uses: codecov/codecov-action@v1 | ||
if: matrix.node-version == 14 | ||
with: | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ node_modules | |
coverage | ||
dist/ | ||
.vscode | ||
yarn.lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* eslint max-len: 0 */ | ||
import fn from '../dist/get-video-id.js'; | ||
|
||
/** | ||
* Dailymotion should be able to find these patterns: | ||
* | ||
* Urls: | ||
* http://www.dailymotion.com/video/id_title_text | ||
* http://www.dailymotion.com/video/id | ||
* http://www.dailymotion.com/fr/relevance/search/search+query/1#video=id | ||
* https://www.dailymotion.com/video/id?playlist= | ||
* https://www.dailymotion.com/embed/video/id?autoplay=1 | ||
* http://dai.ly/id | ||
* | ||
* Not supported (channel id only): | ||
* http://www.dailymotion.com/hub/id_title | ||
*/ | ||
|
||
describe('Dailymotion', () => { | ||
test('Dailymotion basic link/embed', () => { | ||
expect(fn('http://www.dailymotion.com/video/x44lvd_rates-of-exchange-like-a-renegade_music').id).toBe('x44lvd'); | ||
expect(fn('http://www.dailymotion.com/video/x44lvd').id).toBe('x44lvd'); | ||
expect(fn('http://www.dailymotion.com/video/xn1bi0_hakan-yukur-klip_sport').id).toBe('xn1bi0'); | ||
expect(fn('https://www.dailymotion.com/video/x82nygx?playlist=x5nmbq').id).toBe('x82nygx'); | ||
expect(fn('https://www.dailymotion.com/embed/video/x82nygx?autoplay=1').id).toBe('x82nygx'); | ||
expect(fn('http://www.dailymotion.com/fr/relevance/search/gangnam+style/1#video=xsbwie').id).toBe('xsbwie'); | ||
}); | ||
|
||
test('Dailymotion returns the service', () => { | ||
expect(fn('http://www.dailymotion.com/video/1234').service).toBe('dailymotion'); | ||
expect(fn('http://www.dailymotion.com/video/1234').id).toBe('1234'); | ||
}); | ||
|
||
test('Dailymotion short link', () => { | ||
expect(fn('http://dai.ly/x2no31b').id).toBe('x2no31b'); | ||
}); | ||
|
||
test('Dailymotion dynamic id', () => { | ||
expect(fn('http://www.dailymotion.com/fr/relevance/search/gangnam+style/1#video=xsbwie').id).toBe('xsbwie'); | ||
expect(fn('http://www.dailymotion.com/hub/x9q_Galatasaray#video=xjw21s').id).toBe('xjw21s'); | ||
}); | ||
|
||
test('Dailymotion iframe', () => { | ||
const actual = fn('<iframe src="https://www.dailymotion.com/embed/video/12780" width="600" height="600"></iframe>'); | ||
expect(actual.id).toBe('12780'); | ||
expect(actual.service).toBe('dailymotion'); | ||
}); | ||
|
||
test('returns undefined for unknown video ids', () => { | ||
const actual = fn('http://www.dailymotion.com'); | ||
expect(actual.id).toBe(undefined); | ||
expect(actual.service).toBe('dailymotion'); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint max-len: 0 */ | ||
import fn from '../dist/get-video-id.js'; | ||
|
||
/** | ||
* Google redirect patterns: | ||
* https://google.cz/url?source=web&url= | ||
* https://google.com/image?url= | ||
*/ | ||
describe('Google Redirects', () => { | ||
test('handles google redirection to youtube', () => { | ||
const url = 'https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwj30L2MvpDVAhUFZVAKHb8CBaYQuAIIIjAA&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DeG1uDU0rSLw&usg=AFQjCNECyDn3DQL7U6VW2CnXQQjB0gNKqA'; | ||
expect(fn(url).id).toBe('eG1uDU0rSLw'); | ||
expect(fn(url).service).toBe('youtube'); | ||
}); | ||
|
||
test('handles google redirection to dailymotion', () => { | ||
const url = `https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwj30L2MvpDVAhUFZVAKHb8CBaYQuAIIIjAA&url=${encodeURIComponent('http://dai.ly/x2no31b')}&usg=AFQjCNECyDn3DQL7U6VW2CnXQQjB0gNKqA`; | ||
expect(fn(url).id).toBe('x2no31b'); | ||
expect(fn(url).service).toBe('dailymotion'); | ||
}); | ||
|
||
test('handles google redirection to tiktok', () => { | ||
const url = `https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwj30L2MvpDVAhUFZVAKHb8CBaYQuAIIIjAA&url=${encodeURIComponent('https://www.tiktok.com/@brickabrackcommunity/video/6950630446614990085')}&usg=AFQjCNECyDn3DQL7U6VW2CnXQQjB0gNKqA`; | ||
expect(fn(url).id).toBe('6950630446614990085'); | ||
expect(fn(url).service).toBe('tiktok'); | ||
}); | ||
|
||
test('handles google redirection to videopress', () => { | ||
const url = `https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwj30L2MvpDVAhUFZVAKHb8CBaYQuAIIIjAA&url=${encodeURIComponent('https://videopress.com/v/dyrgndFq')}&usg=AFQjCNECyDn3DQL7U6VW2CnXQQjB0gNKqA`; | ||
expect(fn(url).id).toBe('dyrgndFq'); | ||
expect(fn(url).service).toBe('videopress'); | ||
}); | ||
|
||
test('handles google redirection to vine', () => { | ||
const url = `https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwj30L2MvpDVAhUFZVAKHb8CBaYQuAIIIjAA&url=${encodeURIComponent('https://vine.co/v/e5vIvmV5v9J')}&usg=AFQjCNECyDn3DQL7U6VW2CnXQQjB0gNKqA`; | ||
expect(fn(url).id).toBe('e5vIvmV5v9J'); | ||
expect(fn(url).service).toBe('vine'); | ||
}); | ||
|
||
test('handles google redirection to microsoft stream', () => { | ||
const url = `https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwj30L2MvpDVAhUFZVAKHb8CBaYQuAIIIjAA&url=${encodeURIComponent('https://web.microsoftstream.com/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0')}&usg=AFQjCNECyDn3DQL7U6VW2CnXQQjB0gNKqA`; | ||
expect(fn(url).id).toBe('73043e0c-cba8-482a-8a8e-0b72bc580ff0'); | ||
expect(fn(url).service).toBe('microsoftstream'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint max-len: 0 */ | ||
import fn from '../dist/get-video-id.js'; | ||
|
||
test('expects a string', () => { | ||
expect(() => { | ||
fn({}); | ||
}).toThrow(/get-video-id expects a string/); | ||
}); | ||
|
||
test('returns null as id and service', () => { | ||
const notFound = fn('foo'); | ||
expect(notFound.id).toBe(null); | ||
expect(notFound.service).toBe(null); | ||
}); | ||
|
||
test('google link returns null as id and service if missing url parameter', () => { | ||
const url = 'https://www.google.cz/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0ahUKEwiz9P3Aw5DVAhUDZVAKHcegCi8QuAIINDAB&usg=AFQjCNG0kTPdL8nC6zCi2QoZ1KVeTXH-pw'; | ||
expect(fn(url).id).toBe(null); | ||
expect(fn(url).service).toBe(null); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint max-len: 0 */ | ||
import fn from '../dist/get-video-id.js'; | ||
|
||
/** | ||
* Microsoft Stream should be able to find these patterns: | ||
* | ||
* // urls | ||
* https://web.microsoftstream.com/video/id | ||
* | ||
* // iframe | ||
* <iframe src="https://web.microsoftstream.com/embed/video/id" | ||
* | ||
*/ | ||
describe('Microsoft Stream', () => { | ||
test('gets microsoft stream from url', () => { | ||
expect(fn('https://web.microsoftstream.com/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0').id).toBe('73043e0c-cba8-482a-8a8e-0b72bc580ff0'); | ||
expect(fn('https://web.microsoftstream.com/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0?list=trending').id).toBe('73043e0c-cba8-482a-8a8e-0b72bc580ff0'); | ||
expect(fn('https://web.microsoftstream.com/embed/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0').id).toBe('73043e0c-cba8-482a-8a8e-0b72bc580ff0'); | ||
|
||
expect(fn('https://web.microsoftstream.com/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0').service).toBe('microsoftstream'); | ||
expect(fn('https://web.microsoftstream.com/embed/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0').service).toBe('microsoftstream'); | ||
}); | ||
|
||
test('gets microsoft stream metadata from iframe', () => { | ||
const string_ = '<iframe width="640" height="360" src="https://web.microsoftstream.com/embed/video/73043e0c-cba8-482a-8a8e-0b72bc580ff0?autoplay=false&showinfo=true" allowfullscreen style="border:none;"></iframe>'; | ||
|
||
expect(fn(string_).id).toBe('73043e0c-cba8-482a-8a8e-0b72bc580ff0'); | ||
expect(fn(string_).service).toBe('microsoftstream'); | ||
}); | ||
|
||
test('microsoft stream links returns undefined id if id missing', () => { | ||
const object = fn('https://web.microsoftstream.com/video'); | ||
expect(object.id).toBe(undefined); | ||
expect(object.service).toBe('microsoftstream'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint max-len: 0 */ | ||
import fn from '../dist/get-video-id.js'; | ||
|
||
/** | ||
* TikTok should be able to find these patterns: | ||
* | ||
* Urls: | ||
* https://www.tiktok.com/@brickabrackcommunity/video/id | ||
* https://www.tiktok.com/@brickabrackcommunity/video/id? | ||
* | ||
* Not supported yet (requires a fetch): | ||
* https://vm.tiktok.com/ZS9c8yNN/ | ||
*/ | ||
describe('TikTok', () => { | ||
test('Tiktok basic link/embed', () => { | ||
expect(fn('https://www.tiktok.com/@brickabrackcommunity/video/6950630446614990085').id).toBe('6950630446614990085'); | ||
expect(fn('https://www.tiktok.com/@brickabrackcommunity/video/6950630446614990085?lang=fr&is_copy_url=1&is_from_webapp=v1').id).toBe('6950630446614990085'); | ||
expect(fn('https://www.tiktok.com/@brickabrackcommunity/video/6950630446614990085?sender_device=pc&sender_web_id=6930592755036374533&is_from_webapp=v1&is_copy_url=0').id).toBe('6950630446614990085'); | ||
}); | ||
|
||
test('returns undefined for unknown video ids', () => { | ||
const actual = fn('http://www.tiktok.com'); | ||
expect(actual.id).toBe(undefined); | ||
expect(actual.service).toBe('tiktok'); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import fn from '../../src/utils/get-src.js'; | ||
|
||
describe('get-src', () => { | ||
test('expects a string', () => { | ||
expect(() => { | ||
fn(); | ||
}).toThrow(/getSrc expected a string/); | ||
}); | ||
|
||
test('extracts the src from iframe strings', () => { | ||
expect(fn('<iframe src="https://player.vimeo.com/video/abc123"')).toBe('https://player.vimeo.com/video/abc123'); | ||
expect(fn('<iframe src="https://videopress.com/embed/abc123"')).toBe('https://videopress.com/embed/abc123'); | ||
expect(fn(' <iframe src="https://videopress.com/embed/abc123" ')).toBe('https://videopress.com/embed/abc123'); | ||
expect(fn(' <iframe src="https://videopress.com/embed/abc123"')).toBe('https://videopress.com/embed/abc123'); | ||
expect(fn('<iframe width="400" height="300" src="video.mp4"></iframe>')).toBe('video.mp4'); | ||
}); | ||
|
||
test('extracts the source from simple strings', () => { | ||
expect(fn('src="abc123"')).toBe('abc123'); | ||
expect(fn(' src="abc123" ')).toBe('abc123'); | ||
expect(fn(' src="abc123"')).toBe('abc123'); | ||
expect(fn('src="abc123" ')).toBe('abc123'); | ||
}); | ||
|
||
test('extracts the source from html strings', () => { | ||
expect(fn('<image src="image.png" />')).toBe('image.png'); | ||
expect(fn('<source src="audio.mp3" />')).toBe('audio.mp3'); | ||
}); | ||
|
||
test('returns undefined when no src= is found', () => { | ||
expect(fn('hello')).toBe(undefined); | ||
}); | ||
|
||
test('single quotes return undefined', () => { | ||
expect(fn(' src=\'noop\' ')).toBe(undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint max-len: 0 */ | ||
import fn from '../dist/get-video-id.js'; | ||
|
||
/** | ||
* VideoPress should be able to find these patterns: | ||
* | ||
* // urls | ||
* https://videopress.com/v/id | ||
* https://videopress.com/embed/id | ||
* | ||
* // iframe | ||
* <iframe src="https://videopress.com/embed/zcnJVzQF" | ||
* | ||
*/ | ||
|
||
describe('Videopress', () => { | ||
test('gets videopress metadata from url', () => { | ||
expect(fn('https://videopress.com/v/dyrgndFq').id).toBe('dyrgndFq'); | ||
expect(fn('https://videopress.com/v/dyrgndFq#fullscreen').id).toBe('dyrgndFq'); | ||
expect(fn('https://videopress.com/embed/zcnJVzQz?hd=0&autoPlay=0&permalink=0&loop=0').id).toBe('zcnJVzQz'); | ||
|
||
expect(fn('https://videopress.com/embed/zcnJVzQz?hd=0&autoPlay=0&permalink=0&loop=0').service).toBe('videopress'); | ||
}); | ||
|
||
test('gets videopress metadata from iframe', () => { | ||
const string_ = '<iframe width="400" height="300" src="https://videopress.com/embed/zcnJVzQz?hd=0&autoPlay=0&permalink=0&loop=0" frameborder="0" allowfullscreen="" sandbox="allow-same-origin allow-scripts allow-popups"></iframe>'; | ||
expect(fn(string_).id).toBe('zcnJVzQz'); | ||
expect(fn(string_).service).toBe('videopress'); | ||
}); | ||
|
||
test('videopress links returns undefined id if id missing', () => { | ||
const object = fn('https://videopress.com'); | ||
expect(object.id).toBe(undefined); | ||
expect(object.service).toBe('videopress'); | ||
}); | ||
}); |
Oops, something went wrong.