Skip to content

How to write a script

Kurt Bestor edited this page Mar 5, 2024 · 10 revisions

Hitomi Downloader Script file (*.hds, *.py) is basically a Python file.

How to import a script

ToolsImport script... (Alt+S) → Select your script file

Or, You can use it as a plugin: OptionsPreferencesPlugins

Single file Downloader

Here is a simplest Downloader script:

class Downloader_test(Downloader):
    type = 'test'
    URLS = ['test.com']
    single = True

    def read(self):
        self.urls.append('https://www.gstatic.com/webp/gallery/2.jpg')
        self.title = 'test'

URLS is used to detect which downloader should be used for certain URL.

Multiple files Downloader

You can download multiple files in a folder. By removing single = True, It's in multiple files mode. Here is an example:

class Downloader_test(Downloader):
    type = 'test'
    URLS = ['test.com']

    def read(self):
        self.urls.append('https://www.gstatic.com/webp/gallery/2.jpg')
        self.urls.append('https://www.gstatic.com/webp/gallery/3.jpg')
        self.title = 'test'

The self.title becomes the folder name.

Script files

Guide from rickmiron

With Python Interface

There is no file with the classes and methods needed to write the script, so you have to rely on an existing created extractor.

This is a way to solve this problem even a little.

First, download the zip file, after unzipping, paste it into the working folder, and import it from the script

And write code. That's it!

from utils import * # This is an example. After importing only what you need, you can use it.

# Enjoy!

There are many other features. Check out other example scripts.