Compare commits

...

2 Commits

Author SHA1 Message Date
ThePendulum 135fb372f5 1.27.2 2023-06-05 04:11:37 +02:00
ThePendulum da8ffc0025 Fixed RedGIFs gallery support. 2023-06-05 04:11:34 +02:00
5 changed files with 24 additions and 13 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "ripunzel",
"version": "1.27.1",
"version": "1.27.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "ripunzel",
"version": "1.27.1",
"version": "1.27.2",
"license": "ISC",
"dependencies": {
"array.prototype.flatten": "^1.2.1",

View File

@ -1,6 +1,6 @@
{
"name": "ripunzel",
"version": "1.27.1",
"version": "1.27.2",
"description": "Web content archiving tool, with versatile filename patterns and extensive options for reddit user profiles.",
"main": "app.js",
"scripts": {

View File

@ -61,7 +61,7 @@ const hosts = [
{
method: 'redgifs',
label: 'redgifs',
pattern: new UrlPattern('http(s)\\://(:subdomain.)redgifs.com(/watch)/(:id-mobile)(:id)(.:ext)(?*)'),
pattern: new UrlPattern('http(s)\\://(:subdomain.)redgifs.com(/watch)(/i)/(:id-mobile)(:id)(.:ext)(?*)'),
},
{
method: 'erome',

View File

@ -177,7 +177,7 @@ async function fetchSaveDirectContent(content, host, ep) {
}
const filepath = getFilepath(item, content, host, null, null);
const sourcePaths = await save(filepath, buffers, item, null);
const sourcePaths = await save(filepath, buffers.map(({ buffer }) => buffer), item, null);
if (item.mux) {
await mux(filepath, sourcePaths, item);

View File

@ -27,10 +27,10 @@ async function fetchPredata() {
return null;
}
function scrapeGallery(data) {
function scrapeGallery(data, { predata }) {
const oldestDate = Math.min(...data.gifs.map((gif) => gif.createDate));
return {
const curated = {
album: {
id: data.id,
datetime: new Date(oldestDate * 1000),
@ -39,22 +39,33 @@ function scrapeGallery(data) {
id: gif.id,
url: gif.urls.hd,
description: gif.tags.join(', '),
type: mime.getType(gif.urls.hd),
type: mime.getType(new URL(gif.urls.hd).pathname.slice(1)),
datetime: new Date(gif.createDate * 1000),
original: gif,
})),
headers: {
'user-agent': predata.agent,
},
};
return curated;
}
async function fetchGallery(galleryId) {
const res = await fetch(`https://api.redgifs.com/v2/gallery/${galleryId}`);
async function fetchGallery(galleryId, { predata }) {
const res = await fetch(`https://api.redgifs.com/v2/gallery/${galleryId}`, {
headers: {
authorization: `Bearer ${predata.token}`,
'user-agent': predata.agent,
},
});
const data = await res.json();
if (!data.gifs) {
return null;
}
return scrapeGallery(data);
return scrapeGallery(data, { predata });
}
async function redgifsApi(host, post, { predata }) {
@ -76,7 +87,7 @@ async function redgifsApi(host, post, { predata }) {
}
if (data.id && data.gifs) {
return scrapeGallery(data);
return scrapeGallery(data, { predata });
}
if (!data.gif) {
@ -84,7 +95,7 @@ async function redgifsApi(host, post, { predata }) {
}
if (data.gif.gallery) {
return fetchGallery(data.gif.gallery);
return fetchGallery(data.gif.gallery, { predata });
}
const curated = {