Git Product home page Git Product logo

zamzarconverter's Introduction

Zamzar Converter

Allows you to convert Files from Command Line by using Zamzar APIs

โš™๏ธ Prerequisites

  • Zamzar API Key You can get an API Key from this link
  • Python 3.7

๐Ÿท Installation

  1. Clone the Repository
    git clone https://github.com/harshanas/ZamzarConverter.git
    
  2. Install the Requirements
    pip install -r requirements.txt
    
  3. Open config.json file and Insert your API Key

๐Ÿ”จ Usage

To convert a file from epub format to pdf, use the below command

convert.py -s "book.epub" -f "pdf"

๐Ÿ”Ž Arguments that can be parsed

Argument Description Example
-s The path of the file to be converted -s "hello.mp4"
-f The format that files needs to get converted -f "avi"

๐Ÿ™ Huge Thanks

  • To Zamzar devs
  • To the people who view, star, fork clone and contribute to this repository

zamzarconverter's People

Contributors

harshanas avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zamzarconverter's Issues

Unable to converto to mp3

Hi, I'm trying to convert a .docx file to mp3, but I get this error

Traceback (most recent call last):
  File "C:\Users\gedeo\OneDrive\Documenti\Python\Zamzar Converter\convert.py", line 63, in <module>
    jobId = initJobData['id']
KeyError: 'id'

I tried converting it to .pdf and It worked smoothly, so what's the problem here?
Thanks

File download ID causes HTTP 404

It looks like there is an error in the code to kick off the download of a converted file:

download_file(api_key, job_status['id'], file_path+"."+job_status['target_format'])

The code here uses a /job/ID to initiate a file download, whereas a file ID should be used instead. Using the Job ID would cause an HTTP 404 error to be thrown.

The file ID can be found by querying the /job/ID endpoint for a job with a status of successful and interrogating the target_files array. For example in the response below we can see that the file ID to use for download would be 3:

{
    "id" : 15,
    "key" : "GiVUYsF4A8ssq93FR48H",
    "status" : "successful",
    "sandbox" : true,
    "created_at" : "2013-10-27T13:41:00Z",
    "finished_at" : "2013-10-27T13:41:13Z",
    "source_file" : {"id":2,"name":"portrait.gif","size":90571},
    "target_files" : [{"id":3,"name":"portrait.png","size":15311}],
    "target_format" : "png",
    "credit_cost" : 1
}

You may wish to modify the script to have a routine to check the job status before trying to find the file ID, like this:

def check_job(id):
    print ("Checking if job is finished")
    endpoint = "https://sandbox.zamzar.com/v1/jobs/{}".format(job_id)
    response = requests.get(endpoint, auth=HTTPBasicAuth(api_key, ''))
    return json.loads(json.dumps(response.json()))

job_status = ""
job_details = ""
while job_status != "successful" :
     job_details = check_job(job_id)
     job_status = (job_details['status'])
     print (job_status)
     time.sleep(2) 
     if job_status == "successful" :
	break

file_id = (job_details['target_files'][0]['id'])

...

If you would like to chat further let me know, I'm one of the lead developers for the Zamzar API.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.