Skip to content

Commit

Permalink
Language customization
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfleischer committed Apr 5, 2024
1 parent 216f60b commit 2e3d55f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

Emacs package to query and download subtitles from [[https://www.opensubtitles.com/en/home][opensubtitles.com]].

Set up an account at [[https://www.opensubtitles.com/en/home][opensubtitles.com]]; get an API key and set it in =opensub-api-key=. Language preference is set in the
user profile on the website.
Set up an account at [[https://www.opensubtitles.com/en/home][opensubtitles.com]]; get an API key and set it in =opensub-api-key=. Add languages using
=opensub-languages= variable.

To run, call ~M-x opensub~, provide a query string such as *matrix* or *office s04e13*. Select the relevant file among the
options, and it will be downloaded to =opensub-download-directory=. See example:

[[./image.png]]


Issues and PR are welcome.
Issues and PR are welcome! 📺
Binary file modified image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion opensub.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
"Directory where subtitles will be downloaded to."
:type 'directory)

(defcustom opensub-languages '("en")
"Languages to search for; 2 letter codes."
:type '(repeat string))

(defvar opensub--json-fn
(if (version<= "27.1" emacs-version)
(lambda () (json-parse-buffer :object-type 'alist))
Expand All @@ -71,7 +75,9 @@
(url-request-extra-headers
`(("Api-Key" . ,opensub-api-key)
("Content-Type" . "application/json")))
(url (format "https://api.opensubtitles.com/api/v1/subtitles?query=%s"
(url (format (concat "https://api.opensubtitles.com/api/v1/subtitles?query=%s"
(format "&languages=%s"
(string-join (sort opensub-languages #'string<) ",")))
clean-query)))
(opensub--curl url)))

Expand Down

0 comments on commit 2e3d55f

Please sign in to comment.