mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Update AccountImport
This commit is contained in:
parent
e6301bfa51
commit
5a2d7e3eca
1 changed files with 15 additions and 13 deletions
|
@ -348,16 +348,18 @@
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Facebook and Instagram are encoding UTF8 characters in a weird way in their json
|
async fixFacebookEncoding(string) {
|
||||||
// here is a good explanation what's going wrong https://sorashi.github.io/fix-facebook-json-archive-encoding
|
// Facebook and Instagram are encoding UTF8 characters in a weird way in their json
|
||||||
fixFacebookEncoding(string) {
|
// here is a good explanation what's going wrong https://sorashi.github.io/fix-facebook-json-archive-encoding
|
||||||
const replaced = string.replace(/\\u00([a-f0-9]{2})/g, (x) => String.fromCharCode(parseInt(x.slice(2), 16)));
|
// See https://github.com/pixelfed/pixelfed/pull/4726 for more info
|
||||||
const buffer = Array.from(replaced, (c) => c.charCodeAt(0));
|
const replaced = string.replace(/\\u00([a-f0-9]{2})/g, (x) => String.fromCharCode(parseInt(x.slice(2), 16)));
|
||||||
return new TextDecoder().decode(new Uint8Array(buffer));
|
const buffer = Array.from(replaced, (c) => c.charCodeAt(0));
|
||||||
},
|
return new TextDecoder().decode(new Uint8Array(buffer));
|
||||||
|
},
|
||||||
|
|
||||||
filterPostMeta(media) {
|
async filterPostMeta(media) {
|
||||||
let json = JSON.parse(this.fixFacebookEncoding(media));
|
let fbfix = await this.fixFacebookEncoding(media);
|
||||||
|
let json = JSON.parse(fbfix);
|
||||||
let res = json.filter(j => {
|
let res = json.filter(j => {
|
||||||
let ids = j.media.map(m => m.uri).filter(m => {
|
let ids = j.media.map(m => m.uri).filter(m => {
|
||||||
if(this.config.allow_video_posts == true) {
|
if(this.config.allow_video_posts == true) {
|
||||||
|
@ -408,10 +410,10 @@
|
||||||
})
|
})
|
||||||
.map(async entry => {
|
.map(async entry => {
|
||||||
if(
|
if(
|
||||||
(
|
(
|
||||||
entry.filename.startsWith('media/posts/') ||
|
entry.filename.startsWith('media/posts/') ||
|
||||||
entry.filename.startsWith('media/other/')
|
entry.filename.startsWith('media/other/')
|
||||||
) && (
|
) && (
|
||||||
entry.filename.endsWith('.png') ||
|
entry.filename.endsWith('.png') ||
|
||||||
entry.filename.endsWith('.jpg') ||
|
entry.filename.endsWith('.jpg') ||
|
||||||
entry.filename.endsWith('.mp4')
|
entry.filename.endsWith('.mp4')
|
||||||
|
|
Loading…
Reference in a new issue