jklmli / manga_downloader

Cross-platform, multi-site, multi-threaded manga downloader with over 5000 distinct mangas. Includes support for automated downloading via external .xml file and conversion for viewing on the Kindle.
MIT License
270 stars 53 forks source link

Allow XML to use paths relative to DOWNLOADPATH #33

Closed smvz closed 10 years ago

smvz commented 11 years ago

manga.py -x example.xml -d /path/to/manga

example.xml:

<?xml version="1.0" ?>
<root>
    <MangaSeries>
        <name>Manga 1</name>
        <HostSite>MangaReader</HostSite>
        <downloadPath>manga1</downloadPath>
    </MangaSeries>
    ...
</root>

Running the above command with the example XML file should create and use /path/to/manga/manga1 but currently it will create the manga1 directory alongside manga.py

Alternatively the XML parsing could be extended to include a download path that the manga paths should be relative to, keeping the information in one place, i.e.

<root>
    <downloadPath>/path/to/manga</downloadPath>
    <MangaSeries>
        ...
    ...
</root>
smvz commented 10 years ago

Probably too much of an edge case to be worth changing, but it's worth noting that the merged fix will not allow separate absolute paths in the XML.

i.e. "-d /home/user/dir1" with "/home/user/dir2" will result in "/home/user/dir1/home/user/dir2"

jklmli commented 10 years ago

Yeah, can hack around this by checking to see if the path starts with a delimiter slash - I'll get around to it eventually, but feel free to submit a pull request.

smvz commented 10 years ago

Oh, I did just spot a problem actually. It seems to be caused by self.options.downloadPath being set for a manga, then read again for the next manga.

Say you have "-d /home/user" and three entries in the XML as dir1, dir2 and dir3. It downloads into these locations respectively: /home/user/dir1 /home/user/dir1/dir2 /home/user/dir1/dir2/dir3