Skip to content

Repository files navigation

Tigerra Converter PYTHON-SDK

Overview

This documentation provides an overview of the Tigerra Converter library, which allows for various file conversions including audio, video, image, document, and font conversions. Additionally, it supports applying audio effects.

Installation

To use the Tigerra Converter library, you need to include the required dependencies using Composer:

git clone https://github.com/Tigerra-com/convert-python-sdk.git
cd convert-python-sdk
pip3 install requests
python3 index.py

Usage

Basic Example

Below is an example of how to use the Tigerra Converter python-sdk to convert an audio file from FLAC to WAV: (index.py file.)

importtimefromConverterimportConverterfromConversionStatusCheckerimportConversionStatusCheckerfromConverterFileDownloaderimportConverterFileDownloaderfromConverterDeletePidimportConverterDeletePidtry:
auth_token="your_auth_token"# Start conversionprint("Uploading file..")
converter=Converter(auth_token)
conversion_response=converter.audio("flac-to-wav", "/path/to/file/1.flac")
pid=conversion_response['pid']
print(f"Conversion started. PID: {pid}")
# Check statusstatus_checker=ConversionStatusChecker(auth_token)
whileTrue:
status_response=status_checker.check_status(pid)
status=status_response['status']
print(f"Status: {status}")
ifstatus==ConversionStatusChecker.STATUS_COMPLETED:
breakelifstatusin [
ConversionStatusChecker.STATUS_UPLOAD_ERROR,
ConversionStatusChecker.STATUS_PROCESS_ERROR,
ConversionStatusChecker.STATUS_CONVERT_ERROR
]:
raiseException(f"Error occurred: {status}")
time.sleep(2)
# Download filedownload_url=status_response['data']
downloader=ConverterFileDownloader(auth_token)
output_path="/path/to/file/downloaded_file.wav"downloader.download_file(download_url, output_path)
print(f"File downloaded to: {output_path}")
# Delete PIDdelete_pid=ConverterDeletePid(auth_token)
r=delete_pid.delete(pid)
ifr['success']:
print("PID deleted successfully.")
else:
print(f"Error deleting PID: {r['message']}")
exceptExceptionase:
print(f"Error: {e}")

Converter Class

The Converter class provides methods for different types of conversions:

  • audio(conversionType, filePath)
  • video(conversionType, filePath)
  • image(conversionType, filePath)
  • document(conversionType, filePath)
  • font(conversionType, filePath)
  • pdf_compress(filePath)
  • audio_effect(effectType, filePath, [])

Each method sends a request to the appropriate endpoint to perform the conversion or apply the effect. About the audio_effect method types nad $conversionType's, read them from tiggera.com documentation.