Download personal follow manga database

Joined
May 30, 2020
Messages
14
I want to have downloadable manga list just in case. I try using tachiyomi fork neko to sync and then make a backup but it only export like 90% of reading list and none of other list (completed, plan to read, on hold, rereading, dropped). Maybe because it's a third party.
 
Custom title
Staff
Developer
Joined
Jan 19, 2018
Messages
2,456
In the browser devtools console of a mangadex.org tab where you're logged in,

JavaScript:
(await (await fetch("https://api.mangadex.org/user/follows/manga?limit=100&offset=0", {headers:{Authorization:"Bearer "+JSON.parse(localStorage.getItem("oidc.user:https://auth.mangadex.org/realms/mangadex:mangadex-frontend-stable")).access_token}})).json()).data

Repeat while moving the offset by +100 until there's fewer than 100 items in the response

No I won't bother programming that part
 
File Attacher
Staff
Super Moderator
Joined
Jan 20, 2018
Messages
256
And if you're only interested in the titles, instead of lugging around everything in data from the code above you can slap on something like this at the end
JavaScript:
.map((e)=>Object.assign({},e.attributes.title,e.attributes.altTitles.reduce((o,key)=>({...o,[Object.keys(key)]:Object.values(key)[0]}),{})))
And with it reduced like that it's easy enough to just tack on a .en or some other language if you're only interested in one (assuming the series has a title in said language so you'd have to check that first and else fall back to something else if not ) :nyoron:
(though, really the only thing this helps with is consolidate all titles into a single object.. instead of the array with individual objects for each)
Edit: Oh right, forgot about the main title, for some reason the my first title i saw in the data i fetched had the same english title as the main and an alt title.. derp
Edit2: Updated it to grab the main title too haha, seems to work
 
Last edited:
MD@Home
Joined
Oct 15, 2020
Messages
2,220
Improved version 😉

• Loop over 100++ follow list
• Save result to .txt file

JavaScript:
var loop = true
var offset = 0
var fulllist = []
var bearer = "oidc.user:https://auth.mangadex.org/realms/mangadex:mangadex-frontend-stable"

while (loop) {
    var list =
        (await (await fetch(
            "https://api.mangadex.org/user/follows/manga?limit=100&offset=" + offset, {
                headers: {
                    Authorization: "Bearer " + JSON.parse(localStorage.getItem(bearer)).access_token
                }
            }
        )).json()).data
                  .map(val => val.attributes.title)
                  .map(val => val[Object.keys(val)[0]] + '\n')

    loop = list.length ? true : false;
    offset += 100;
    fulllist = fulllist.concat(list)
}

var link = document.createElement("a")
var file = new Blob(fulllist.sort(), { type: 'text/plain' })

link.href = URL.createObjectURL(file)
link.download = "MangaDex Manga List.txt"
link.click()
URL.revokeObjectURL(link.href)
 
File Attacher
Staff
Super Moderator
Joined
Jan 20, 2018
Messages
256
Improved version 😉

• Loop over 100++ follow list
• Save result to .txt file

JavaScript:
var loop = true
var offset = 0
var fulllist = []
var bearer = "oidc.user:https://auth.mangadex.org/realms/mangadex:mangadex-frontend-stable"

while (loop) {
    var list =
        (await (await fetch(
            "https://api.mangadex.org/user/follows/manga?limit=100&offset=" + offset, {
                headers: {
                    Authorization: "Bearer " + JSON.parse(localStorage.getItem(bearer)).access_token
                }
            }
        )).json()).data
                  .map(val => val.attributes.title)
                  .map(val => val[Object.keys(val)[0]] + '\n')

    loop = list.length ? true : false;
    offset += 100;
    fulllist = fulllist.concat(list)
}

var link = document.createElement("a")
var file = new Blob(fulllist.sort(), { type: 'text/plain' })

link.href = URL.createObjectURL(file)
link.download = "MangaDex Manga List.txt"
link.click()
URL.revokeObjectURL(link.href)

Can't that technically get rate limited? even if it is very unlikely, well anyway, since we're at it and posting an entire script have my messy expanded one (in that you can get any and all titles a series has) while borrowing the last part of yours

JavaScript:
{
    let _onlyMain = false; //Set to True if you only want the "Main" title.
    let _langs = ['en']; //If Empty will grab any and all titles of the series, only works if the one above is false.
    let _offset = _resTotal = 0;
    let _out = [];
    let _token = JSON.parse(localStorage.getItem("oidc.user:https://auth.mangadex.org/realms/mangadex:mangadex-frontend-stable")).access_token;
    do{
        let rls = Date.now();
        let res = (await (await fetch("https://api.mangadex.org/user/follows/manga?limit=100&offset="+_offset,{headers:{Authorization:"Bearer "+_token}})).json());
        _resTotal = res.total;
        let data = res.data;
        if(!_onlyMain){
            let tmp = data.map((e)=>{
                let titles = e.attributes.altTitles.concat(e.attributes.title).filter(f=>_langs.length>0?_langs.includes(Object.keys(f)[0]):true).map(i=>Object.values(i)[0]).sort().join(' | ');
                return (titles == '' ? Object.values(e.attributes.title)[0] : titles)+'\n';
            });
            _out.push(...tmp);
        }else{
            _out.push(...data.map((e)=>Object.values(e.attributes.title)[0]+'\n'));
        }
        _offset += 100;
        let rld = Date.now() - rls;
        if(rld < 200) await new Promise((rs)=>{setTimeout(rs,200-rld)});
    }while(_resTotal - _offset > 0)
      
    let link = document.createElement("a")
    let file = new Blob(_out.sort(), { type: 'text/plain' })

    link.href = URL.createObjectURL(file)
    link.download = "MangaDex Manga List.txt"
    link.click()
    URL.revokeObjectURL(link.href)
}
 

Users who are viewing this thread

Top