mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-12 13:17:45 +02:00
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:
@ -1,6 +1,7 @@
|
||||
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) {
|
||||
let id = o.id;
|
||||
@ -19,15 +20,24 @@ export default async function(o) {
|
||||
|
||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||
|
||||
let videoLink = [...html.matchAll(linkRegex)]
|
||||
let videoLink = [...html.matchAll(videoRegex)]
|
||||
.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' };
|
||||
|
||||
return {
|
||||
if (videoLink) return {
|
||||
urls: videoLink,
|
||||
filename: `pinterest_${o.id}.mp4`,
|
||||
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
|
||||
},
|
||||
"pinterest": {
|
||||
"alias": "pinterest videos & stories",
|
||||
"alias": "pinterest (all media)",
|
||||
"patterns": ["pin/:id", "pin/:id/:garbage", "url_shortener/:shortLink"],
|
||||
"enabled": true
|
||||
},
|
||||
|
Reference in New Issue
Block a user