fix: google album redirect url (#4814)

This commit is contained in:
hoilc
2020-05-19 16:26:06 +08:00
committed by GitHub
parent 57d7abc5b3
commit ee30e7fb54

View File

@@ -3,13 +3,11 @@ const got = require('@/utils/got');
module.exports = async (ctx) => { module.exports = async (ctx) => {
const id = ctx.params.id; const id = ctx.params.id;
const url = `https://photos.app.goo.gl/${id}`; const url = `https://photos.app.goo.gl/${id}?_imcp=1`;
const init_response = await got.get(url); const response = await got.get(url);
const real_url = init_response.data.match(/data-destination="(.*?)"/)[1]; const real_url = response.request.options.url.href;
const response = await got.get(real_url);
const info = JSON.parse(response.data.match(/AF_initDataCallback.*?return ([\s\S]*?)}}\)/m)[1]) || []; const info = JSON.parse(response.data.match(/AF_initDataCallback.*?return ([\s\S]*?)}}\)/m)[1]) || [];
@@ -23,7 +21,7 @@ module.exports = async (ctx) => {
link: url, link: url,
item: list.slice(0, 50).map((item) => { item: list.slice(0, 50).map((item) => {
const time = new Date(item[2] * 1); const time = new Date(item[2] * 1);
const isVideo = Object.keys(item[13]).length > 2; // uncertain const isVideo = Object.keys(item[15]).length > 2; // uncertain
const description = isVideo ? `<video src="${item[1][0]}=m18" controls controlslist="nodownload" loop style="max-width: 100%;">` : `<img src="${item[1][0]}=w${item[1][1]}-h${item[1][2]}-no" style="max-width: 100%;">`; const description = isVideo ? `<video src="${item[1][0]}=m18" controls controlslist="nodownload" loop style="max-width: 100%;">` : `<img src="${item[1][0]}=w${item[1][1]}-h${item[1][2]}-no" style="max-width: 100%;">`;
return { return {
title: time.toLocaleString(), title: time.toLocaleString(),