Skip to content

Commit

Permalink
mdn: remove large video replacing
Browse files Browse the repository at this point in the history
Part of #445
  • Loading branch information
myfreeer committed Apr 22, 2023
1 parent 305bf22 commit 261fe94
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 64 deletions.
18 changes: 1 addition & 17 deletions src/mdn/process-url/consts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { arrayToMap } from 'website-scrap-engine/lib/util';
import {arrayToMap} from 'website-scrap-engine/lib/util';

export const localeArr = [
'af', 'ar', 'az', 'bg',
Expand Down Expand Up @@ -72,19 +72,3 @@ export const downloadableHosts = arrayToMap([
'developer-stage.mdn.mozit.cloud',
'developer-prod.mdn.mozit.cloud'
]);

// manually collected
export const largeMp4Videos = arrayToMap([
'/learning-area/javascript/apis/video-audio/finished/video/sintel-short.mp4',
'/html-examples/link-rel-preload/video/sintel-short.mp4',
'/imsc/videos/coffee.mp4',
'/imsc/videos/stars.mp4',
'/dom-examples/fullscreen-api/assets/bigbuckbunny.mp4',
'/dom-examples/picture-in-picture/assets/bigbuckbunny.mp4'
]);

// manually collected
export const largeWebmVideos = arrayToMap([
'/learning-area/javascript/apis/video-audio/finished/video/sintel-short.webm',
'/html-examples/link-rel-preload/video/sintel-short.webm'
]);
10 changes: 0 additions & 10 deletions src/mdn/process-url/redirect-download-link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {Resource} from 'website-scrap-engine/lib/resource';
import {largeMp4Videos, largeWebmVideos} from './consts';
import URI from 'urijs';

export const redirectDownloadLink = (res: Resource): Resource => {
Expand Down Expand Up @@ -31,15 +30,6 @@ export const redirectDownloadLink = (res: Resource): Resource => {
// mdn.github.io
// redirect back to real url
path = path.slice('/mdn-github-io'.length);
// redirect large videos to small ones
// https://github.com/myfreeer/mdn-local/issues/46
if (largeMp4Videos[path]) {
path = '/learning-area/html/multimedia-and-embedding/' +
'video-and-audio-content/rabbit320.mp4';
} else if (largeWebmVideos[path]) {
path = '/learning-area/html/multimedia-and-embedding/' +
'video-and-audio-content/rabbit320.webm';
}
res.downloadLink = uri.search('')
.host('mdn.github.io')
.path(path)
Expand Down
40 changes: 3 additions & 37 deletions test/mdn/process-url/redirect-download-link.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import type {
DownloadOptions,
StaticDownloadOptions
} from 'website-scrap-engine/lib/options';
import {redirectDownloadLink} from '../../../src/mdn/process-url/redirect-download-link';
import {
redirectDownloadLink
} from '../../../src/mdn/process-url/redirect-download-link';
import URI = require('urijs');

const opt = (locale: string): StaticDownloadOptions => ({
Expand Down Expand Up @@ -101,42 +103,6 @@ describe('redirect-download-link', function () {
}
});

// https://github.com/myfreeer/mdn-local/issues/46
test('mdn.github.io large mp4 video', () => {
const urls = [
'https://mdn.github.io//learning-area/javascript/apis/video-audio/finished/video/sintel-short.mp4',
'https://mdn.github.io/html-examples//link-rel-preload/video/sintel-short.mp4',
'https://mdn.github.io/../imsc/videos/coffee.mp4',
'https://mdn.github.io/imsc/videos/stars.mp4'
];
for (const url of urls) {
const resource = res(url);
redirectDownloadLink(resource);
expect(resource.uri?.path().startsWith('/mdn-github-io/')).toBeTruthy();
expect(resource.uri?.host()).toBe('developer.mozilla.org');
expect(resource.downloadLink).toBe('https://mdn.github.io' +
'/learning-area/html/multimedia-and-embedding/' +
'video-and-audio-content/rabbit320.mp4');
}
});

//https://github.com/myfreeer/mdn-local/issues/46
test('mdn.github.io large webm video', () => {
const urls = [
'https://mdn.github.io/learning-area/javascript/apis/video-audio/finished/video/sintel-short.webm',
'https://mdn.github.io//html-examples/link-rel-preload/video/sintel-short.webm'
];
for (const url of urls) {
const resource = res(url);
redirectDownloadLink(resource);
expect(resource.uri?.path().startsWith('/mdn-github-io/')).toBeTruthy();
expect(resource.uri?.host()).toBe('developer.mozilla.org');
expect(resource.downloadLink).toBe('https://mdn.github.io' +
'/learning-area/html/multimedia-and-embedding/' +
'video-and-audio-content/rabbit320.webm');
}
});

// commit f11a10c439357164877bb15fd50029ac80c519b6
// 2020/3/28 16:32
test('unpkg.com', () => {
Expand Down

0 comments on commit 261fe94

Please sign in to comment.