NAV
python

EPUB.to API ප්‍රලේඛනය වෙත සාදරයෙන් පිළිගනිමු

සංවර්ධක යතුරක් ලබා ගැනීමට කරුණාකර යන්නසංවර්ධක ද්වාරය

Authorization: <api_key>

EPUB වෙතින් පරිවර්තනය කරන්න

EPUB සිට PDF දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-pdf'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.pdf

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

MOBI වෙත EPUB

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-mobi'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.mobi

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට AZW3 දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-azw3'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.azw3

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට FB2 දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-fb2'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.fb2

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට CBZ දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-cbz'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.cbz

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට CBR දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-cbr'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.cbr

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට DOCX දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-docx'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.docx

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPOC සිට DOC දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-doc'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.doc

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

HTML වෙත EPUB

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-html'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.html

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

RTU වෙත EPUB

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-rtf'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.rtf

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට PNG දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-png'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.png

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට SVG දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-svg'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.svg

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට JPG දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-jpg'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.jpg

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට BMP දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-bmp'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.bmp

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට ZIP දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-zip'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.zip

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට GIF දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-gif'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.gif

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB සිට TIFF දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.epub', 'testfiles/blah.epub', 'testfiles/blah.epub']
params = {
    'lang': 'en',
    'convert_to': 'epub-tiff'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.tiff

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

EPUB බවට පරිවර්තනය කරන්න

PDF සිට EPUB

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-epub'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.epub

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

DOCX සිට EPUB දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-epub'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.epub

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න

DOC සිට EPUB දක්වා

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.doc', 'testfiles/blah.doc', 'testfiles/blah.doc']
params = {
    'lang': 'en',
    'convert_to': 'doc-epub'
}

api_url = 'https://api.epub.to/v1/convert/'
results_url = 'https://api.epub.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.epub.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

නැවත පැමිණෙනු ඇත

/path/to/local/file_processed.epub

බහු සෑදීමට ඔබේ ලැයිස්තුවට තවත් ගොනු දමන්න