Skip to content

Python script to get a subtitle file from OpenSubtitles new REST API

Notifications You must be signed in to change notification settings

tomburke25/python-opensubtitles-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-opensubtitles-rest-api

Module to get a subtitle from OpenSubtitles

Uses the new REST API at https://opensubtitles.stoplight.io/

Requires an account at OpenSubtitles.com

You will need to create an API key in your account

API is currently in BETA

Basic Usage:

Create a credentials file called .credentials:

{ 'username' : 'YOURUSER' , 'password': 'YOURPASS', 'api-key': 'YOURAPIKEY' }
import open_subtitles
os = open_subtitles.OpenSubtitles()
os.login()
file_info = os.get_subtitle_file_info("/my/video/file.mkv", "en", True)
os.download_subtitle(file_info['file_no'])

Breakdown of functions

Search for a subtitle:

get_subtitle_file_info(full_file_path, sublanguage, forced)
  • full_file_path = required
  • sublanguage = required
  • forced = optional (default=False)

Returns dictionary:

{ file_no : XXXXX, file_name: XXXX }

Download subtitle:

download_subtitle(file_no, output_directory, output_filename, overwrite)
  • file_no = required
  • output_directory = optional (default=same as video file)
  • output_filename = optional (default=same as video file)
  • overwrite = optional (default=False)

FileOperations module contains code for the hashing from the XML-RPC implementation by Alexandre González at: https://raw.githubusercontent.com/agonzalezro/python-opensubtitles

About

Python script to get a subtitle file from OpenSubtitles new REST API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages