pinterest: implement image and gifs support (#475)
Co-authored-by: jj <log@riseup.net> Co-authored-by: wukko <me@wukko.me>
This commit is contained in:
parent
bd16aec699
commit
5c9ecb2781
4 changed files with 50 additions and 8 deletions
|
@ -42,7 +42,7 @@ this list is not final and keeps expanding over time. if support for a service y
|
||||||
| service | notes or features |
|
| service | notes or features |
|
||||||
| :-------- | :----- |
|
| :-------- | :----- |
|
||||||
| instagram | supports photos, videos, and stories. lets you pick what to save from multi-media posts. |
|
| instagram | supports photos, videos, and stories. lets you pick what to save from multi-media posts. |
|
||||||
| pinterest | supports videos and stories. |
|
| pinterest | supports photos, gifs, videos and stories. |
|
||||||
| reddit | supports gifs and videos. |
|
| reddit | supports gifs and videos. |
|
||||||
| soundcloud | supports private links. |
|
| soundcloud | supports private links. |
|
||||||
| tiktok | supports videos with or without watermark, images from slideshow without watermark, and full (original) audios. |
|
| tiktok | supports videos with or without watermark, images from slideshow without watermark, and full (original) audios. |
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { genericUserAgent } from "../../config.js";
|
import { genericUserAgent } from "../../config.js";
|
||||||
|
|
||||||
const linkRegex = /"url":"(https:\/\/v1.pinimg.com\/videos\/.*?)"/g;
|
const videoRegex = /"url":"(https:\/\/v1.pinimg.com\/videos\/.*?)"/g;
|
||||||
|
const imageRegex = /src="(https:\/\/i\.pinimg\.com\/.*\.(jpg|gif))"/g;
|
||||||
|
|
||||||
export default async function(o) {
|
export default async function(o) {
|
||||||
let id = o.id;
|
let id = o.id;
|
||||||
|
@ -19,15 +20,24 @@ export default async function(o) {
|
||||||
|
|
||||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
let videoLink = [...html.matchAll(linkRegex)]
|
let videoLink = [...html.matchAll(videoRegex)]
|
||||||
.map(([, link]) => link)
|
.map(([, link]) => link)
|
||||||
.filter(a => a.endsWith('.mp4') && a.includes('720p'))[0];
|
.find(a => a.endsWith('.mp4') && a.includes('720p'));
|
||||||
|
|
||||||
if (!videoLink) return { error: 'ErrorEmptyDownload' };
|
if (videoLink) return {
|
||||||
|
|
||||||
return {
|
|
||||||
urls: videoLink,
|
urls: videoLink,
|
||||||
filename: `pinterest_${o.id}.mp4`,
|
filename: `pinterest_${o.id}.mp4`,
|
||||||
audioFilename: `pinterest_${o.id}_audio`
|
audioFilename: `pinterest_${o.id}_audio`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let imageLink = [...html.matchAll(imageRegex)]
|
||||||
|
.map(([, link]) => link)
|
||||||
|
.find(a => a.endsWith('.jpg') || a.endsWith('.gif'));
|
||||||
|
|
||||||
|
if (imageLink) return {
|
||||||
|
urls: imageLink,
|
||||||
|
isPhoto: true
|
||||||
|
}
|
||||||
|
|
||||||
|
return { error: 'ErrorEmptyDownload' };
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
"pinterest": {
|
"pinterest": {
|
||||||
"alias": "pinterest videos & stories",
|
"alias": "pinterest (all media)",
|
||||||
"patterns": ["pin/:id", "pin/:id/:garbage", "url_shortener/:shortLink"],
|
"patterns": ["pin/:id", "pin/:id/:garbage", "url_shortener/:shortLink"],
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
|
|
|
@ -976,6 +976,38 @@
|
||||||
"code": 200,
|
"code": 200,
|
||||||
"status": "redirect"
|
"status": "redirect"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"name": "regular picture",
|
||||||
|
"url": "https://www.pinterest.com/pin/412994228343400946/",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "redirect"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "regular picture (.ca TLD)",
|
||||||
|
"url": "https://www.pinterest.ca/pin/412994228343400946/",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "redirect"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "regular gif",
|
||||||
|
"url": "https://www.pinterest.com/pin/814447913881127862/",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "redirect"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "regular gif (.ca TLD)",
|
||||||
|
"url": "https://www.pinterest.ca/pin/814447913881127862/",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "redirect"
|
||||||
|
}
|
||||||
}],
|
}],
|
||||||
"streamable": [{
|
"streamable": [{
|
||||||
"name": "regular video",
|
"name": "regular video",
|
||||||
|
|
Loading…
Reference in a new issue