I wanna be able to export my library into a file

Dex-chan lover
Joined
May 16, 2019
Messages
1,153
The main thing I missed when the site went down was my Manga follows. I couldn't work with the API and login through that. It'd be great if the website had an option to let me download my follows to a file to keep as backup, even a simple text file.

I see there was a support thread about this topic, but I don't think it's been actually suggested yet.
 
Upvote 19
Dex-chan lover
Joined
Sep 26, 2019
Messages
1,027
I just want to be able to export my library as a simple text file—even if it's just the titles and authors.

I've been an otaku since the early 2000s, and I've seen many sites rise and fall. Mangadex has probably been my favorite so far. But the sad reality, especially with the DMCA, is that at some point it might either shut down or go fully legal—which would be amazing, but it would also mean a lot of titles could be lost in the process. Either way, it would be really nice to have a text backup of my library from a few months before that happens, just to know what I had when the time comes.
Yep just lost a f ton of manga i was reading and have no idea what was my last read chapter. This is why i liked apps like mangarock it kept a record of last chapter.
The last read chapter is the big one for me. I have no idea where I was in a lot of the series I was reading.
 
Supporter
Joined
Jul 25, 2023
Messages
5
Here is my script based on RogueKitsune's work on previous page

What does it do:
  • Produces Anilist compatible xml export out of user's Mangadex Library.
    • Doesn't likely work in MyAnimeList (haven't tested).
  • Only list of mangas and read status are transferred. Thus score, read volumes, read chapters or other such things are NOT transferred. Might work on those later.
  • MyAnimeList id is used for linking, so many smaller works will be left out. (Might work to fix this later).
  • Is really slow (there is wait of 1s per manga, to comply with Mangadex's API limits).
  • It is barely tested, but seems to work thus far with my machine and my library.
Anilist import page where the output can be used

@RogueKitsune thanks for the original code.

JavaScript:
async function GetLibrary(readingStatus) {
    const baseUrl = 'https://api.mangadex.org';
    const authToken = JSON.parse(localStorage.getItem('oidc.user:https://auth.mangadex.org/realms/mangadex:mangadex-frontend-stable')).access_token;
    
    let fetchUrl = `${baseUrl}/manga/status`;
    
    if(readingStatus !== '')
        fetchUrl = `${fetchUrl}?status=${readingStatus}`
    
    let response = await fetch(fetchUrl, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${authToken}`,
        },
    });
    return await response.json();
}

async function GetAttributes(titleId) {
    const baseUrl = 'https://api.mangadex.org';
    
    let response = await fetch(`${baseUrl}/manga/${titleId}`, {
        method: 'GET',
        headers: {
            'Content-Type': 'application/json',
        },
    });
    
    const result = await response.json();
    return result.data.attributes;
}

function Sleep(milliseconds) {
    return new Promise((resolve) => setTimeout(resolve, milliseconds))
}

function MakeXmlData(libData) {
    let output = "<?xml version='1.0' encoding='UTF-8' ?>";
    output += "<myanimelist>";

    for(const row of libData) {
        output += "<manga>";
        
        for (const key of Object.keys(row)) {
            output += "<" + key + ">";
            output += row[key];
            output += "</" + key + ">";
        }
        
        output += "</manga>";
    }
    
    output += "</myanimelist>";
    return output;
}

function DownloadXml(xmlData) {
    const blob = new Blob([xmlData], {type:'text/zml'});
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = 'library.xml';
    a.click();
}

function ConvertStatus(mdStatus) {
    return {
        reading: 'Reading',
        completed: 'Completed',
        on_hold: 'On hold',
        plan_to_read: 'Plan to Read',
        dropped: 'Dropped',
        re_reading: 'Re-reading'
    }[mdStatus];
}

function Sanitize(str) {
    if (!str) {
        return str;
    }
    return str.replace( '&', '&amp;' ).replace( '<', '&lt;').replace( '>', '&gt;');
}

(async () => {
    const readingStatus = ''; // empty for all titles
    const result = await GetLibrary(readingStatus);
    const libInfo = [];
    for(const id in result.statuses) {
        const attributes = await GetAttributes(id);
        const titles = attributes.title;
        let title = Object.hasOwn(titles, 'en') ? titles['en'] : titles[Object.keys(titles)[0]];
        title = Sanitize(title);
        
        if (!attributes.links?.mal && !attributes.links?.al) {
            continue;
        }
        libInfo.push({
            manga_mangadb_id: attributes.links?.mal, 
            manga_anilist_id: attributes.links?.al,
            
            my_status: ConvertStatus(result.statuses[id]),
            
            manga_title: title,
            my_read_volumes: 0,
            my_read_chapters: 0,
            my_start_date: "0000-00-00",
            my_finish_date: "0000-00-00",
            my_score: 0
        });
        await Sleep(1000);
    }
    
    console.log(libInfo);
    DownloadXml(MakeXmlData(libInfo));
})();
 
Last edited:
Dex-chan lover
Joined
Jan 8, 2023
Messages
748
Here is my script based on RogueKitsune's work on previous page

What does it do:
  • Produces Anilist compatible xml export out of user's Mangadex Library.
    • Doesn't likely work in MyAnimeList (haven't tested).
  • Only list of mangas and read status are transferred. Thus score, read volumes, read chapters or other such things are NOT transferred. Might work on those later.
  • MyAnimeList id is used for linking, so many smaller works will be left out. (Might work to fix this later).
  • Is really slow (there is wait of 1s per manga, to comply with Mangadex's API limits).
  • It is barely tested, but seems to work thus far with my machine and my library.
Anilist import page where the output can be used

@RogueKitsune thanks for the original code.
Thank you so much!! Seriously!!!!! In order for this to be useful for me I'll have to wait for read chapters to be in here, but this is incredible!!
 
Dex-chan lover
Joined
Apr 30, 2020
Messages
941
I was thinking they should also add an export option for your read history.

Anyways, I’m using mangadex as an “app,” so the site data is not in the browser. I have no idea where it is.
 
Member
Joined
Jan 18, 2018
Messages
51
There is r/mangadex post someone made a script and .exe that export the list through Api.
It works but the results is messy.
 

Users who are viewing this thread

Top