Skip to content

Commit

Permalink
process-url: redirect a large video
Browse files Browse the repository at this point in the history
Fix #938
  • Loading branch information
myfreeer committed Oct 3, 2023
1 parent e4a683b commit 24e1dbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ createDownloader({
.catch(console.error);

```

## Large video handling

A large video has been replaced into a much smaller trailer for faster download of the package, get it back from [the original link](https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4) or [here](https://github.com/website-local/assets/releases/download/mdn-local/big_buck_bunny_720p_surround.mp4);
10 changes: 10 additions & 0 deletions src/mdn/process-url/redirect-download-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import type {Resource} from 'website-scrap-engine/lib/resource';
import URI from 'urijs';
import {externalHosts} from './consts';

const replacements = [
// https://github.com/website-local/mdn-local/issues/938
'https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4',
// A much smaller file from http://download.blender.org/peach/trailer/trailer_iphone.m4v
'https://github.com/website-local/assets/releases/download/mdn-local/trailer_iphone.mp4',
];

export const redirectDownloadLink = (res: Resource): Resource => {
const url = res.downloadLink;
let uri, path;
Expand All @@ -27,6 +34,9 @@ export const redirectDownloadLink = (res: Resource): Resource => {
.host(externalHost.host)
.path(path.slice(externalHost.pathPrefixLength))
.toString();
if (res.downloadLink === replacements[0]) {
res.downloadLink = replacements[1];
}
return res;
}
}
Expand Down

0 comments on commit 24e1dbe

Please sign in to comment.