1SUBLIMINAL(1) subliminal SUBLIMINAL(1)
2
3
4
6 subliminal - subliminal Documentation
7
8 Subliminal is a python 2.7+ library to search and download subtitles.
9 It comes with an easy to use yet powerful CLI suitable for direct use
10 or cron jobs.
11
13 Usage
14 CLI
15 Download English subtitles:
16
17 $ subliminal download -l en The.Big.Bang.Theory.S05E18.HDTV.x264-LOL.mp4
18 Collecting videos [####################################] 100%
19 1 video collected / 0 video ignored
20 Downloading subtitles [####################################] 100%
21 Downloaded 1 subtitle
22
23 WARNING:
24 For cron usage, make sure to specify a maximum age (with --age) so
25 subtitles are searched for recent videos only. Otherwise you will
26 get banned from the providers for abuse due to too many requests. If
27 subliminal didn’t find subtitles for an old video, it’s unlikely it
28 will find subtitles for that video ever anyway.
29
30 See cli for more details on the available commands and options.
31
32 Nautilus/Nemo integration
33 See the dedicated project page for more information.
34
35 High level API
36 You can call subliminal in many different ways depending on how much
37 control you want over the process. For most use cases, you can stick to
38 the standard API.
39
40 Common
41 Let’s start by importing subliminal:
42
43 >>> import os
44 >>> from babelfish import *
45 >>> from subliminal import *
46
47 Before going further, there are a few things to know about subliminal.
48
49 Video
50 The Movie and Episode classes represent a video, existing or not. You
51 can create a video by name (or path) with Video.fromname, use
52 scan_video() on an existing file path to get even more information
53 about the video or use scan_videos() on an existing directory path to
54 scan a whole directory for videos.
55
56 >>> video = Video.fromname('The.Big.Bang.Theory.S05E18.HDTV.x264-LOL.mp4')
57 >>> video
58 <Episode ['The Big Bang Theory', 5x18]>
59
60 Here video information was guessed based on the name of the video, you
61 can access some video attributes:
62
63 >>> video.video_codec
64 'h264'
65 >>> video.release_group
66 'LOL'
67
68 Configuration
69 Before proceeding to listing and downloading subtitles, you need to
70 configure the cache. Subliminal uses a cache to reduce repeated queries
71 to providers and improve overall performance with no impact on search
72 quality. For the sake of this example, we’re going to use a memory
73 backend.
74
75 >>> my_region = region.configure('dogpile.cache.memory')
76
77 WARNING:
78 Choose a cache that fits your application and prefer persistent over
79 volatile backends. The file backend is usually a good choice. See
80 dogpile.cache’s documentation for more details on backends.
81
82 Now that we’re done with the basics, let’s have some real fun.
83
84 Listing
85 To list subtitles, subliminal provides a list_subtitles() function that
86 will return all found subtitles:
87
88 >>> subtitles = list_subtitles([video], {Language('hun')}, providers=['podnapisi'])
89 >>> subtitles[video]
90 [<PodnapisiSubtitle 'ZtAW' [hu]>, <PodnapisiSubtitle 'ONAW' [hu]>]
91
92 NOTE:
93 As you noticed, all parameters are iterables but only contain one
94 item which means you can deal with a lot of videos, languages and
95 providers at the same time. For the sake of this example, we filter
96 providers to use only one, pass providers=None (default) to search
97 on all providers.
98
99 Scoring
100 It’s usual you have multiple candidates for subtitles. To help you
101 chose which one to download, subliminal can compare them to the video
102 and tell you exactly what matches with get_matches():
103
104 >>> for s in subtitles[video]:
105 ... sorted(s.get_matches(video))
106 ['episode', 'format', 'release_group', 'season', 'series', 'video_codec', 'year']
107 ['episode', 'format', 'season', 'series', 'year']
108
109 And then compute a score with those matches with compute_score():
110
111 >>> for s in subtitles[video]:
112 ... {s: compute_score(s, video)}
113 {<PodnapisiSubtitle 'ZtAW' [hu]>: 354}
114 {<PodnapisiSubtitle 'ONAW' [hu]>: 337}
115
116 Now you should have a better idea about which one you should choose.
117
118 Downloading
119 We can settle on the first subtitle and download its content using
120 download_subtitles():
121
122 >>> subtitle = subtitles[video][0]
123 >>> subtitle.content is None
124 True
125 >>> download_subtitles([subtitle])
126 >>> subtitle.content.split(b'\n')[2]
127 b'Elszaladok a boltba'
128
129 If you want a string instead of bytes, you can access decoded content
130 with the text property:
131
132 >>> subtitle.text.split('\n')[3]
133 'néhány apróságért.'
134
135 Downloading best subtitles
136 Downloading best subtitles is what you want to do in almost all cases,
137 as a shortcut for listing, scoring and downloading you can use down‐
138 load_best_subtitles():
139
140 >>> best_subtitles = download_best_subtitles([video], {Language('hun')}, providers=['podnapisi'])
141 >>> best_subtitles[video]
142 [<PodnapisiSubtitle 'ZtAW' [hu]>]
143 >>> best_subtitle = best_subtitles[video][0]
144 >>> best_subtitle.content.split(b'\n')[2]
145 b'Elszaladok a boltba'
146
147 We end up with the same subtitle but with one line of code. Neat.
148
149 Save
150 We got ourselves a nice subtitle, now we can save it on the file system
151 using save_subtitles():
152
153 >>> save_subtitles(video, [best_subtitle])
154 [<PodnapisiSubtitle 'ZtAW' [hu]>]
155 >>> os.listdir()
156 ['The.Big.Bang.Theory.S05E18.HDTV.x264-LOL.hu.srt']
157
158 How it works
159 Providers
160 Subliminal uses multiple providers to give users a vast choice and have
161 a better chance to find the best matching subtitles. Current supported
162 providers are:
163
164 · Addic7ed
165
166 · LegendasTV
167
168 · NapiProjekt
169
170 · OpenSubtitles
171
172 · Podnapisi
173
174 · Shooter
175
176 · SubsCenter
177
178 · TheSubDB
179
180 · TvSubtitles
181
182 Providers all inherit the same Provider base class and thus share the
183 same API. They are registered on the subliminal.providers entry point
184 and are exposed through the provider_manager for easy access.
185
186 To work with multiple providers seamlessly, the ProviderPool exposes
187 the same API but distributes it to its providers and AsyncProviderPool
188 does it asynchronously.
189
190 Scoring
191 Rating subtitles and comparing them is probably the most difficult part
192 and this is where subliminal excels with its powerful scoring algo‐
193 rithm.
194
195 Using guessit and enzyme, subliminal extracts properties of the video
196 and match them with the properties of the subtitles found with the
197 providers.
198
199 Equations in subliminal.score give a score to each property (called a
200 match). The more matches the video and the subtitle have, the higher
201 the score computed with compute_score() gets.
202
203 Libraries
204 Various libraries are used by subliminal and are key to its success:
205
206 · guessit to guess information from filenames
207
208 · enzyme to detect embedded subtitles in videos and read other video
209 metadata
210
211 · babelfish to work with languages
212
213 · requests to make human readable HTTP requests
214
215 · BeautifulSoup to parse HTML and XML
216
217 · dogpile.cache to cache intermediate search results
218
219 · stevedore to manage the provider entry point
220
221 · chardet to detect subtitles’ encoding
222
223 · pysrt to validate downloaded subtitles
224
225 CLI
226 subliminal
227 Usage: subliminal [OPTIONS] COMMAND [ARGS]...
228
229 Subtitles, faster than your thoughts.
230
231 Options:
232 --addic7ed USERNAME PASSWORD Addic7ed configuration.
233 --legendastv USERNAME PASSWORD LegendasTV configuration.
234 --opensubtitles USERNAME PASSWORD
235 OpenSubtitles configuration.
236 --subscenter USERNAME PASSWORD SubsCenter configuration.
237 --cache-dir DIRECTORY Path to the cache directory. [default:
238 /builddir/.cache/subliminal]
239 --debug Print useful information for debugging
240 subliminal and for reporting bugs.
241 --version Show the version and exit.
242 --help Show this message and exit.
243
244 Commands:
245 cache Cache management.
246 download Download best subtitles.
247
248 Suggestions and bug reports are greatly appreciated:
249 https://github.com/Diaoul/subliminal/
250
251 subliminal download
252 Usage: subliminal download [OPTIONS] PATH...
253
254 Download best subtitles.
255
256 PATH can be an directory containing videos, a video file path or a video
257 file name. It can be used multiple times.
258
259 If an existing subtitle is detected (external or embedded) in the correct
260 language, the download is skipped for the associated video.
261
262 Options:
263 -l, --language LANGUAGE Language as IETF code, e.g. en, pt-BR (can
264 be used multiple times). [required]
265 -p, --provider [addic7ed|legendastv|opensubtitles|podnapisi|shooter|subscenter|thesubdb|tvsubtitles]
266 Provider to use (can be used multiple
267 times).
268 -r, --refiner [metadata|omdb|tvdb]
269 Refiner to use (can be used multiple times).
270 -a, --age AGE Filter videos newer than AGE, e.g. 12h,
271 1w2d.
272 -d, --directory DIR Directory where to save subtitles, default
273 is next to the video file.
274 -e, --encoding ENC Subtitle file encoding, default is to
275 preserve original encoding.
276 -s, --single Save subtitle without language code in the
277 file name, i.e. use .srt extension. Do not
278 use this unless your media player requires
279 it.
280 -f, --force Force download even if a subtitle already
281 exist.
282 -hi, --hearing-impaired Prefer hearing impaired subtitles.
283 -m, --min-score INTEGER RANGE Minimum score for a subtitle to be
284 downloaded (0 to 100).
285 -w, --max-workers INTEGER RANGE
286 Maximum number of threads to use.
287 -z, --archives / -Z, --no-archives
288 Scan archives for videos (supported
289 extensions: .rar). [default: True]
290 -v, --verbose Increase verbosity.
291 --help Show this message and exit.
292
293 subliminal cache
294 Usage: subliminal cache [OPTIONS]
295
296 Cache management.
297
298 Options:
299 --clear-subliminal Clear subliminal's cache. Use this ONLY if your cache is
300 corrupted or if you experience issues.
301 --help Show this message and exit.
302
303 Provider Guide
304 This guide is going to explain how to add a Provider to subliminal. You
305 are encouraged to take a look at the existing providers, it can be a
306 nice base to start your own provider.
307
308 Requirements
309 When starting a provider you should be able to answer to the following
310 questions:
311
312 · What languages does my provider support?
313
314 · What are the language codes for the supported languages?
315
316 · Does my provider deliver subtitles for episodes? for movies?
317
318 · Does my provider require a video hash?
319
320 Each response of these questions will help you set the correct
321 attributes for your Provider.
322
323 Video Validation
324 Not all providers deliver subtitles for Episode. Some may require a
325 hash. The check() method does validation against a Video object and
326 will return False if the given Video isn’t suitable. If you’re not
327 happy with the default implementation, you can override it.
328
329 Configuration
330 API keys must not be configurable by the user and must remain linked to
331 subliminal. Hence they must be written in the provider module.
332
333 Per-user authentication is allowed and must be configured at instantia‐
334 tion as keyword arguments. Configuration will be done by the user
335 through the provider_configs argument of the list_subtitles() and down‐
336 load_best_subtitles() functions. No network operation must be done dur‐
337 ing instantiation, only configuration. Any error in the configuration
338 must raise a ConfigurationError.
339
340 Beyond this point, if an error occurs, a generic ProviderError excep‐
341 tion must be raised. You can also use more explicit exception classes
342 AuthenticationError and DownloadLimitExceeded.
343
344 Initialization / Termination
345 Actual authentication operations must take place in the initialize()
346 method. If you need anything to be executed when the provider isn’t
347 used anymore like logout, use terminate().
348
349 Caching policy
350 To save bandwidth and improve querying time, intermediate data should
351 be cached when possible. Typical use case is when a query to retrieve
352 show ids is required prior to the query to actually search for subti‐
353 tles. In that case the function that gets the show id from the show
354 name must be cached. Expiration time should be SHOW_EXPIRATION_TIME
355 for shows and EPISODE_EXPIRATION_TIME for episodes.
356
357 Language
358 To be able to handle various language codes, subliminal makes use of
359 babelfish Language and converters. You must set the attribute languages
360 with a set of supported Language.
361
362 If you cannot find a suitable converter for your provider, you can make
363 one of your own.
364
365 Querying
366 The query() method parameters must include all aspects of provider’s
367 querying with primary types.
368
369 Subtitle
370 A custom Subtitle subclass must be created to represent a subtitle from
371 the provider. It must have relevant attributes that can be used to
372 compute the matches of the subtitle against a Video object.
373
374 Score computation
375 To be able to compare subtitles coming from different providers between
376 them, the get_matches() method must be implemented.
377
378 Unittesting
379 All possible uses of query(), list_subtitles() and download_subtitle()
380 methods must have integration tests. Use vcrpy for recording and play‐
381 back of network activity. Other functions must be unittested. If nec‐
382 essary, you can use unittest.mock to mock some functions.
383
385 If you are looking for information on a specific function, class or
386 method, this part of the documentation is for you.
387
388 Core
389 subliminal.core.ARCHIVE_EXTENSIONS
390 Supported archive extensions
391
392 class subliminal.core.ProviderPool(providers=None, provider_con‐
393 figs=None)
394 A pool of providers with the same API as a single Provider.
395
396 It has a few extra features:
397
398 · Lazy loads providers when needed and supports the with
399 statement to terminate() the providers on exit.
400
401 · Automatically discard providers on failure.
402
403 Parameters
404
405 · providers (list) – name of providers to use, if not
406 all.
407
408 · provider_configs (dict) – provider configuration as
409 keyword arguments per provider name to pass when
410 instanciating the Provider.
411
412 providers = None
413 Name of providers to use
414
415 provider_configs = None
416 Provider configuration
417
418 initialized_providers = None
419 Initialized providers
420
421 discarded_providers = None
422 Discarded providers
423
424 list_subtitles_provider(provider, video, languages)
425 List subtitles with a single provider.
426
427 The video and languages are checked against the provider.
428
429 Parameters
430
431 · provider (str) – name of the provider.
432
433 · video (Video) – video to list subtitles for.
434
435 · languages (set of Language) – languages to
436 search for.
437
438 Returns
439 found subtitles.
440
441 Return type
442 list of Subtitle or None
443
444 list_subtitles(video, languages)
445 List subtitles.
446
447 Parameters
448
449 · video (Video) – video to list subtitles for.
450
451 · languages (set of Language) – languages to
452 search for.
453
454 Returns
455 found subtitles.
456
457 Return type
458 list of Subtitle
459
460 download_subtitle(subtitle)
461 Download subtitle’s content.
462
463 Parameters
464 subtitle (Subtitle) – subtitle to download.
465
466 Returns
467 True if the subtitle has been successfully down‐
468 loaded, False otherwise.
469
470 Return type
471 bool
472
473 download_best_subtitles(subtitles, video, languages,
474 min_score=0, hearing_impaired=False, only_one=False, com‐
475 pute_score=None)
476 Download the best matching subtitles.
477
478 Parameters
479
480 · subtitles (list of Subtitle) – the subtitles to
481 use.
482
483 · video (Video) – video to download subtitles for.
484
485 · languages (set of Language) – languages to down‐
486 load.
487
488 · min_score (int) – minimum score for a subtitle
489 to be downloaded.
490
491 · hearing_impaired (bool) – hearing impaired pref‐
492 erence.
493
494 · only_one (bool) – download only one subtitle,
495 not one per language.
496
497 · compute_score – function that takes subtitle and
498 video as positional arguments, hearing_impaired
499 as keyword argument and returns the score.
500
501 Returns
502 downloaded subtitles.
503
504 Return type
505 list of Subtitle
506
507 terminate()
508 Terminate all the initialized_providers.
509
510 class subliminal.core.AsyncProviderPool(max_workers=None, *args,
511 **kwargs)
512 Subclass of ProviderPool with asynchronous support for
513 list_subtitles().
514
515 Parameters
516 max_workers (int) – maximum number of threads to use. If
517 None, max_workers will be set to the number of providers.
518
519 max_workers = None
520 Maximum number of threads to use
521
522 list_subtitles_provider(provider, video, languages)
523 List subtitles with a single provider.
524
525 The video and languages are checked against the provider.
526
527 Parameters
528
529 · provider (str) – name of the provider.
530
531 · video (Video) – video to list subtitles for.
532
533 · languages (set of Language) – languages to
534 search for.
535
536 Returns
537 found subtitles.
538
539 Return type
540 list of Subtitle or None
541
542 list_subtitles(video, languages)
543 List subtitles.
544
545 Parameters
546
547 · video (Video) – video to list subtitles for.
548
549 · languages (set of Language) – languages to
550 search for.
551
552 Returns
553 found subtitles.
554
555 Return type
556 list of Subtitle
557
558 subliminal.core.check_video(video, languages=None, age=None, unde‐
559 fined=False)
560 Perform some checks on the video.
561
562 All the checks are optional. Return False if any of this check
563 fails:
564
565 · languages already exist in video’s subtitle_languages.
566
567 · video is older than age.
568
569 · video has an undefined language in subtitle_languages.
570
571 Parameters
572
573 · video (Video) – video to check.
574
575 · languages (set of Language) – desired languages.
576
577 · age (datetime.timedelta) – maximum age of the video.
578
579 · undefined (bool) – fail on existing undefined language.
580
581 Returns
582 True if the video passes the checks, False otherwise.
583
584 Return type
585 bool
586
587 subliminal.core.search_external_subtitles(path, directory=None)
588 Search for external subtitles from a video path and their asso‐
589 ciated language.
590
591 Unless directory is provided, search will be made in the same
592 directory as the video file.
593
594 Parameters
595
596 · path (str) – path to the video.
597
598 · directory (str) – directory to search for subtitles.
599
600 Returns
601 found subtitles with their languages.
602
603 Return type
604 dict
605
606 subliminal.core.scan_video(path)
607 Scan a video from a path.
608
609 Parameters
610 path (str) – existing path to the video.
611
612 Returns
613 the scanned video.
614
615 Return type
616 Video
617
618 subliminal.core.scan_archive(path)
619 Scan an archive from a path.
620
621 Parameters
622 path (str) – existing path to the archive.
623
624 Returns
625 the scanned video.
626
627 Return type
628 Video
629
630 subliminal.core.scan_videos(path, age=None, archives=True)
631 Scan path for videos and their subtitles.
632
633 See refine() to find additional information for the video.
634
635 Parameters
636
637 · path (str) – existing directory path to scan.
638
639 · age (datetime.timedelta) – maximum age of the video or
640 archive.
641
642 · archives (bool) – scan videos in archives.
643
644 Returns
645 the scanned videos.
646
647 Return type
648 list of Video
649
650 subliminal.core.refine(video, episode_refiners=None, movie_refin‐
651 ers=None, **kwargs)
652 Refine a video using refiners.
653
654 NOTE:
655 Exceptions raised in refiners are silently passed and logged.
656
657 Parameters
658
659 · video (Video) – the video to refine.
660
661 · episode_refiners (tuple) – refiners to use for
662 episodes.
663
664 · movie_refiners (tuple) – refiners to use for movies.
665
666 · **kwargs – additional parameters for the refine() func‐
667 tions.
668
669 subliminal.core.list_subtitles(videos, languages, pool_class=<class
670 'subliminal.core.ProviderPool'>, **kwargs)
671 List subtitles.
672
673 The videos must pass the languages check of check_video().
674
675 Parameters
676
677 · videos (set of Video) – videos to list subtitles for.
678
679 · languages (set of Language) – languages to search for.
680
681 · pool_class (ProviderPool, AsyncProviderPool or similar)
682 – class to use as provider pool.
683
684 · **kwargs – additional parameters for the provided
685 pool_class constructor.
686
687 Returns
688 found subtitles per video.
689
690 Return type
691 dict of Video to list of Subtitle
692
693 subliminal.core.download_subtitles(subtitles, pool_class=<class 'sub‐
694 liminal.core.ProviderPool'>, **kwargs)
695 Download content of subtitles.
696
697 Parameters
698
699 · subtitles (list of Subtitle) – subtitles to download.
700
701 · pool_class (ProviderPool, AsyncProviderPool or similar)
702 – class to use as provider pool.
703
704 · **kwargs – additional parameters for the provided
705 pool_class constructor.
706
707 subliminal.core.download_best_subtitles(videos, languages, min_score=0,
708 hearing_impaired=False, only_one=False, compute_score=None,
709 pool_class=<class 'subliminal.core.ProviderPool'>, **kwargs)
710 List and download the best matching subtitles.
711
712 The videos must pass the languages and undefined (only_one)
713 checks of check_video().
714
715 Parameters
716
717 · videos (set of Video) – videos to download subtitles
718 for.
719
720 · languages (set of Language) – languages to download.
721
722 · min_score (int) – minimum score for a subtitle to be
723 downloaded.
724
725 · hearing_impaired (bool) – hearing impaired preference.
726
727 · only_one (bool) – download only one subtitle, not one
728 per language.
729
730 · compute_score – function that takes subtitle and video
731 as positional arguments, hearing_impaired as keyword
732 argument and returns the score.
733
734 · pool_class (ProviderPool, AsyncProviderPool or similar)
735 – class to use as provider pool.
736
737 · **kwargs – additional parameters for the provided
738 pool_class constructor.
739
740 Returns
741 downloaded subtitles per video.
742
743 Return type
744 dict of Video to list of Subtitle
745
746 subliminal.core.save_subtitles(video, subtitles, single=False, direc‐
747 tory=None, encoding=None)
748 Save subtitles on filesystem.
749
750 Subtitles are saved in the order of the list. If a subtitle with
751 a language has already been saved, other subtitles with the same
752 language are silently ignored.
753
754 The extension used is .lang.srt by default or .srt is single is
755 True, with lang being the IETF code for the language of the sub‐
756 title.
757
758 Parameters
759
760 · video (Video) – video of the subtitles.
761
762 · subtitles (list of Subtitle) – subtitles to save.
763
764 · single (bool) – save a single subtitle, default is to
765 save one subtitle per language.
766
767 · directory (str) – path to directory where to save the
768 subtitles, default is next to the video.
769
770 · encoding (str) – encoding in which to save the subti‐
771 tles, default is to keep original encoding.
772
773 Returns
774 the saved subtitles
775
776 Return type
777 list of Subtitle
778
779 Video
780 subliminal.video.VIDEO_EXTENSIONS
781 Video extensions
782
783 class subliminal.video.Video(name, format=None, release_group=None,
784 resolution=None, video_codec=None, audio_codec=None, imdb_id=None,
785 hashes=None, size=None, subtitle_languages=None)
786 Base class for videos.
787
788 Represent a video, existing or not.
789
790 Parameters
791
792 · name (str) – name or path of the video.
793
794 · format (str) – format of the video (HDTV, WEB-DL, Blu‐
795 Ray, …).
796
797 · release_group (str) – release group of the video.
798
799 · resolution (str) – resolution of the video stream
800 (480p, 720p, 1080p or 1080i).
801
802 · video_codec (str) – codec of the video stream.
803
804 · audio_codec (str) – codec of the main audio stream.
805
806 · imdb_id (str) – IMDb id of the video.
807
808 · hashes (dict) – hashes of the video file by provider
809 names.
810
811 · size (int) – size of the video file in bytes.
812
813 · subtitle_languages (set) – existing subtitle languages.
814
815 name = None
816 Name or path of the video
817
818 format = None
819 Format of the video (HDTV, WEB-DL, BluRay, …)
820
821 release_group = None
822 Release group of the video
823
824 resolution = None
825 Resolution of the video stream (480p, 720p, 1080p or
826 1080i)
827
828 video_codec = None
829 Codec of the video stream
830
831 audio_codec = None
832 Codec of the main audio stream
833
834 imdb_id = None
835 IMDb id of the video
836
837 hashes = None
838 Hashes of the video file by provider names
839
840 size = None
841 Size of the video file in bytes
842
843 subtitle_languages = None
844 Existing subtitle languages
845
846 exists Test whether the video exists
847
848 age Age of the video
849
850 classmethod fromguess(name, guess)
851 Create an Episode or a Movie with the given name based on
852 the guess.
853
854 Parameters
855
856 · name (str) – name of the video.
857
858 · guess (dict) – guessed data.
859
860 Raise ValueError if the type of the guess is invalid
861
862 classmethod fromname(name)
863 Shortcut for fromguess() with a guess guessed from the
864 name.
865
866 Parameters
867 name (str) – name of the video.
868
869 class subliminal.video.Episode(name, series, season, episode,
870 title=None, year=None, original_series=True, tvdb_id=None,
871 series_tvdb_id=None, series_imdb_id=None, **kwargs)
872 Episode Video.
873
874 Parameters
875
876 · series (str) – series of the episode.
877
878 · season (int) – season number of the episode.
879
880 · episode (int) – episode number of the episode.
881
882 · title (str) – title of the episode.
883
884 · year (int) – year of the series.
885
886 · original_series (bool) – whether the series is the
887 first with this name.
888
889 · tvdb_id (int) – TVDB id of the episode.
890
891 · **kwargs – additional parameters for the Video con‐
892 structor.
893
894 series = None
895 Series of the episode
896
897 season = None
898 Season number of the episode
899
900 episode = None
901 Episode number of the episode
902
903 title = None
904 Title of the episode
905
906 year = None
907 Year of series
908
909 original_series = None
910 The series is the first with this name
911
912 tvdb_id = None
913 TVDB id of the episode
914
915 series_tvdb_id = None
916 TVDB id of the series
917
918 series_imdb_id = None
919 IMDb id of the series
920
921 classmethod fromguess(name, guess)
922 Create an Episode or a Movie with the given name based on
923 the guess.
924
925 Parameters
926
927 · name (str) – name of the video.
928
929 · guess (dict) – guessed data.
930
931 Raise ValueError if the type of the guess is invalid
932
933 classmethod fromname(name)
934 Shortcut for fromguess() with a guess guessed from the
935 name.
936
937 Parameters
938 name (str) – name of the video.
939
940 class subliminal.video.Movie(name, title, year=None, **kwargs)
941 Movie Video.
942
943 Parameters
944
945 · title (str) – title of the movie.
946
947 · year (int) – year of the movie.
948
949 · **kwargs – additional parameters for the Video con‐
950 structor.
951
952 title = None
953 Title of the movie
954
955 year = None
956 Year of the movie
957
958 classmethod fromguess(name, guess)
959 Create an Episode or a Movie with the given name based on
960 the guess.
961
962 Parameters
963
964 · name (str) – name of the video.
965
966 · guess (dict) – guessed data.
967
968 Raise ValueError if the type of the guess is invalid
969
970 classmethod fromname(name)
971 Shortcut for fromguess() with a guess guessed from the
972 name.
973
974 Parameters
975 name (str) – name of the video.
976
977 Subtitle
978 subliminal.subtitle.SUBTITLE_EXTENSIONS
979 Subtitle extensions
980
981 class subliminal.subtitle.Subtitle(language, hearing_impaired=False,
982 page_link=None, encoding=None)
983 Base class for subtitle.
984
985 Parameters
986
987 · language (Language) – language of the subtitle.
988
989 · hearing_impaired (bool) – whether or not the subtitle
990 is hearing impaired.
991
992 · page_link (str) – URL of the web page from which the
993 subtitle can be downloaded.
994
995 · encoding (str) – Text encoding of the subtitle.
996
997 provider_name = ''
998 Name of the provider that returns that class of subtitle
999
1000 language = None
1001 Language of the subtitle
1002
1003 hearing_impaired = None
1004 Whether or not the subtitle is hearing impaired
1005
1006 page_link = None
1007 URL of the web page from which the subtitle can be down‐
1008 loaded
1009
1010 content = None
1011 Content as bytes
1012
1013 encoding = None
1014 Encoding to decode with when accessing text
1015
1016 id Unique identifier of the subtitle
1017
1018 text Content as string
1019
1020 If encoding is None, the encoding is guessed with
1021 guess_encoding()
1022
1023 is_valid()
1024 Check if a text is a valid SubRip format.
1025
1026 Returns
1027 whether or not the subtitle is valid.
1028
1029 Return type
1030 bool
1031
1032 guess_encoding()
1033 Guess encoding using the language, falling back on
1034 chardet.
1035
1036 Returns
1037 the guessed encoding.
1038
1039 Return type
1040 str
1041
1042 get_matches(video)
1043 Get the matches against the video.
1044
1045 Parameters
1046 video (Video) – the video to get the matches with.
1047
1048 Returns
1049 matches of the subtitle.
1050
1051 Return type
1052 set
1053
1054 subliminal.subtitle.get_subtitle_path(video_path, language=None, exten‐
1055 sion='.srt')
1056 Get the subtitle path using the video_path and language.
1057
1058 Parameters
1059
1060 · video_path (str) – path to the video.
1061
1062 · language (Language) – language of the subtitle to put
1063 in the path.
1064
1065 · extension (str) – extension of the subtitle.
1066
1067 Returns
1068 path of the subtitle.
1069
1070 Return type
1071 str
1072
1073 subliminal.subtitle.guess_matches(video, guess, partial=False)
1074 Get matches between a video and a guess.
1075
1076 If a guess is partial, the absence information won’t be counted
1077 as a match.
1078
1079 Parameters
1080
1081 · video (Video) – the video.
1082
1083 · guess (dict) – the guess.
1084
1085 · partial (bool) – whether or not the guess is partial.
1086
1087 Returns
1088 matches between the video and the guess.
1089
1090 Return type
1091 set
1092
1093 subliminal.subtitle.fix_line_ending(content)
1094 Fix line ending of content by changing it to
1095
1096 param bytes content
1097 content of the subtitle.
1098
1099 return the content with fixed line endings.
1100
1101 rtype bytes
1102
1103 Providers
1104 class subliminal.providers.TimeoutSafeTransport(timeout, *args,
1105 **kwargs)
1106 Timeout support for xmlrpc.client.SafeTransport.
1107
1108 class subliminal.providers.ParserBeautifulSoup(markup, parsers,
1109 **kwargs)
1110 A bs4.BeautifulSoup that picks the first parser available in
1111 parsers.
1112
1113 Parameters
1114
1115 · markup – markup for the bs4.BeautifulSoup.
1116
1117 · parsers (list) – parser names, in order of preference.
1118
1119 class subliminal.providers.Provider
1120 Base class for providers.
1121
1122 If any configuration is possible for the provider, like creden‐
1123 tials, it must take place during instantiation.
1124
1125 Raise ConfigurationError if there is a configuration error
1126
1127 languages = set()
1128 Supported set of Language
1129
1130 video_types = (<class 'subliminal.video.Episode'>, <class 'sub‐
1131 liminal.video.Movie'>)
1132 Supported video types
1133
1134 required_hash = None
1135 Required hash, if any
1136
1137 initialize()
1138 Initialize the provider.
1139
1140 Must be called when starting to work with the provider.
1141 This is the place for network initialization or login
1142 operations.
1143
1144 NOTE:
1145 This is called automatically when entering the with
1146 statement
1147
1148 terminate()
1149 Terminate the provider.
1150
1151 Must be called when done with the provider. This is the
1152 place for network shutdown or logout operations.
1153
1154 NOTE:
1155 This is called automatically when exiting the with
1156 statement
1157
1158 classmethod check(video)
1159 Check if the video can be processed.
1160
1161 The video is considered invalid if not an instance of
1162 video_types or if the required_hash is not present in
1163 hashes attribute of the video.
1164
1165 Parameters
1166 video (Video) – the video to check.
1167
1168 Returns
1169 True if the video is valid, False otherwise.
1170
1171 Return type
1172 bool
1173
1174 query(*args, **kwargs)
1175 Query the provider for subtitles.
1176
1177 Arguments should match as much as possible the actual
1178 parameters for querying the provider
1179
1180 Returns
1181 found subtitles.
1182
1183 Return type
1184 list of Subtitle
1185
1186 Raise ProviderError
1187
1188 list_subtitles(video, languages)
1189 List subtitles for the video with the given languages.
1190
1191 This will call the query() method internally. The parame‐
1192 ters passed to the query() method may vary depending on
1193 the amount of information available in the video.
1194
1195 Parameters
1196
1197 · video (Video) – video to list subtitles for.
1198
1199 · languages (set of Language) – languages to
1200 search for.
1201
1202 Returns
1203 found subtitles.
1204
1205 Return type
1206 list of Subtitle
1207
1208 Raise ProviderError
1209
1210 download_subtitle(subtitle)
1211 Download subtitle’s content.
1212
1213 Parameters
1214 subtitle (Subtitle) – subtitle to download.
1215
1216 Raise ProviderError
1217
1218 Addic7ed
1219 subliminal.providers.addic7ed.series_year_re = re.com‐
1220 pile("^(?P<series>[ \\w\\'.:(),&!?-]+?)(?: \\((?P<year>\\d{4})\\))?$")
1221 Series header parsing regex
1222
1223 class subliminal.providers.addic7ed.Addic7edSubtitle(language, hear‐
1224 ing_impaired, page_link, series, season, episode, title, year, version,
1225 download_link)
1226 Addic7ed Subtitle.
1227
1228 id Unique identifier of the subtitle
1229
1230 get_matches(video)
1231 Get the matches against the video.
1232
1233 Parameters
1234 video (Video) – the video to get the matches with.
1235
1236 Returns
1237 matches of the subtitle.
1238
1239 Return type
1240 set
1241
1242 class subliminal.providers.addic7ed.Addic7edProvider(username=None,
1243 password=None)
1244 Addic7ed Provider.
1245
1246 initialize()
1247 Initialize the provider.
1248
1249 Must be called when starting to work with the provider.
1250 This is the place for network initialization or login
1251 operations.
1252
1253 NOTE:
1254 This is called automatically when entering the with
1255 statement
1256
1257 terminate()
1258 Terminate the provider.
1259
1260 Must be called when done with the provider. This is the
1261 place for network shutdown or logout operations.
1262
1263 NOTE:
1264 This is called automatically when exiting the with
1265 statement
1266
1267 _get_show_ids()
1268 Get the dict of show ids per series by querying the
1269 shows.php page.
1270
1271 Returns
1272 show id per series, lower case and without quotes.
1273
1274 Return type
1275 dict
1276
1277 _search_show_id(series, year=None)
1278 Search the show id from the series and year.
1279
1280 Parameters
1281
1282 · series (str) – series of the episode.
1283
1284 · year (int) – year of the series, if any.
1285
1286 Returns
1287 the show id, if found.
1288
1289 Return type
1290 int
1291
1292 get_show_id(series, year=None, country_code=None)
1293 Get the best matching show id for series, year and coun‐
1294 try_code.
1295
1296 First search in the result of _get_show_ids() and fall‐
1297 back on a search with _search_show_id().
1298
1299 Parameters
1300
1301 · series (str) – series of the episode.
1302
1303 · year (int) – year of the series, if any.
1304
1305 · country_code (str) – country code of the series,
1306 if any.
1307
1308 Returns
1309 the show id, if found.
1310
1311 Return type
1312 int
1313
1314 query(series, season, year=None, country=None)
1315 Query the provider for subtitles.
1316
1317 Arguments should match as much as possible the actual
1318 parameters for querying the provider
1319
1320 Returns
1321 found subtitles.
1322
1323 Return type
1324 list of Subtitle
1325
1326 Raise ProviderError
1327
1328 list_subtitles(video, languages)
1329 List subtitles for the video with the given languages.
1330
1331 This will call the query() method internally. The parame‐
1332 ters passed to the query() method may vary depending on
1333 the amount of information available in the video.
1334
1335 Parameters
1336
1337 · video (Video) – video to list subtitles for.
1338
1339 · languages (set of Language) – languages to
1340 search for.
1341
1342 Returns
1343 found subtitles.
1344
1345 Return type
1346 list of Subtitle
1347
1348 Raise ProviderError
1349
1350 download_subtitle(subtitle)
1351 Download subtitle’s content.
1352
1353 Parameters
1354 subtitle (Subtitle) – subtitle to download.
1355
1356 Raise ProviderError
1357
1358 LegendasTv
1359 subliminal.providers.legendastv.type_map = {'C': 'episode', 'M':
1360 'movie', 'S': 'episode'}
1361 Conversion map for types
1362
1363 subliminal.providers.legendastv.season_re = re.compile(' - (?P<sea‐
1364 son>\\d+)(\\xaa|a|st|nd|rd|th) (temporada|season)', re.IGNORECASE)
1365 BR title season parsing regex
1366
1367 subliminal.providers.legendastv.downloads_re = re.compile('(?P<down‐
1368 loads>\\d+) downloads')
1369 Downloads parsing regex
1370
1371 subliminal.providers.legendastv.rating_re = re.compile('nota (?P<rat‐
1372 ing>\\d+)')
1373 Rating parsing regex
1374
1375 subliminal.providers.legendastv.timestamp_re = re.com‐
1376 pile('(?P<day>\\d+)/(?P<month>\\d+)/(?P<year>\\d+) -
1377 (?P<hour>\\d+):(?P<minute>\\d+)')
1378 Timestamp parsing regex
1379
1380 subliminal.providers.legendastv.releases_key = 'sublimi‐
1381 nal.providers.legendastv:releases|{archive_id}'
1382 Cache key for releases
1383
1384 class subliminal.providers.legendastv.LegendasTVArchive(id, name, pack,
1385 featured, link, downloads=0, rating=0, timestamp=None)
1386 LegendasTV Archive.
1387
1388 Parameters
1389
1390 · id (str) – identifier.
1391
1392 · name (str) – name.
1393
1394 · pack (bool) – contains subtitles for multiple episodes.
1395
1396 · pack – featured.
1397
1398 · link (str) – link.
1399
1400 · downloads (int) – download count.
1401
1402 · rating (int) – rating (0-10).
1403
1404 · timestamp (datetime.datetime) – timestamp.
1405
1406 id = None
1407 Identifier
1408
1409 name = None
1410 Name
1411
1412 pack = None
1413 Pack
1414
1415 featured = None
1416 Featured
1417
1418 link = None
1419 Link
1420
1421 downloads = None
1422 Download count
1423
1424 rating = None
1425 Rating (0-10)
1426
1427 timestamp = None
1428 Timestamp
1429
1430 content = None
1431 Compressed content as rarfile.RarFile or zipfile.ZipFile
1432
1433 class subliminal.providers.legendastv.LegendasTVSubtitle(language,
1434 type, title, year, imdb_id, season, archive, name)
1435 LegendasTV Subtitle.
1436
1437 id Unique identifier of the subtitle
1438
1439 get_matches(video, hearing_impaired=False)
1440 Get the matches against the video.
1441
1442 Parameters
1443 video (Video) – the video to get the matches with.
1444
1445 Returns
1446 matches of the subtitle.
1447
1448 Return type
1449 set
1450
1451 class subliminal.providers.legendastv.LegendasTVProvider(username=None,
1452 password=None)
1453 LegendasTV Provider.
1454
1455 Parameters
1456
1457 · username (str) – username.
1458
1459 · password (str) – password.
1460
1461 initialize()
1462 Initialize the provider.
1463
1464 Must be called when starting to work with the provider.
1465 This is the place for network initialization or login
1466 operations.
1467
1468 NOTE:
1469 This is called automatically when entering the with
1470 statement
1471
1472 terminate()
1473 Terminate the provider.
1474
1475 Must be called when done with the provider. This is the
1476 place for network shutdown or logout operations.
1477
1478 NOTE:
1479 This is called automatically when exiting the with
1480 statement
1481
1482 search_titles(title)
1483 Search for titles matching the title.
1484
1485 Parameters
1486 title (str) – the title to search for.
1487
1488 Returns
1489 found titles.
1490
1491 Return type
1492 dict
1493
1494 get_archives(title_id, language_code)
1495 Get the archive list from a given title_id and lan‐
1496 guage_code.
1497
1498 Parameters
1499
1500 · title_id (int) – title id.
1501
1502 · language_code (int) – language code.
1503
1504 Returns
1505 the archives.
1506
1507 Return type
1508 list of LegendasTVArchive
1509
1510 download_archive(archive)
1511 Download an archive’s content.
1512
1513 Parameters
1514 archive (LegendasTVArchive) – the archive to down‐
1515 load content of.
1516
1517 query(language, title, season=None, episode=None, year=None)
1518 Query the provider for subtitles.
1519
1520 Arguments should match as much as possible the actual
1521 parameters for querying the provider
1522
1523 Returns
1524 found subtitles.
1525
1526 Return type
1527 list of Subtitle
1528
1529 Raise ProviderError
1530
1531 list_subtitles(video, languages)
1532 List subtitles for the video with the given languages.
1533
1534 This will call the query() method internally. The parame‐
1535 ters passed to the query() method may vary depending on
1536 the amount of information available in the video.
1537
1538 Parameters
1539
1540 · video (Video) – video to list subtitles for.
1541
1542 · languages (set of Language) – languages to
1543 search for.
1544
1545 Returns
1546 found subtitles.
1547
1548 Return type
1549 list of Subtitle
1550
1551 Raise ProviderError
1552
1553 download_subtitle(subtitle)
1554 Download subtitle’s content.
1555
1556 Parameters
1557 subtitle (Subtitle) – subtitle to download.
1558
1559 Raise ProviderError
1560
1561 NapiProjekt
1562 subliminal.providers.napiprojekt.get_subhash(hash)
1563 Get a second hash based on napiprojekt’s hash.
1564
1565 Parameters
1566 hash (str) – napiprojekt’s hash.
1567
1568 Returns
1569 the subhash.
1570
1571 Return type
1572 str
1573
1574 class subliminal.providers.napiprojekt.NapiProjektSubtitle(language,
1575 hash)
1576 NapiProjekt Subtitle.
1577
1578 id Unique identifier of the subtitle
1579
1580 get_matches(video)
1581 Get the matches against the video.
1582
1583 Parameters
1584 video (Video) – the video to get the matches with.
1585
1586 Returns
1587 matches of the subtitle.
1588
1589 Return type
1590 set
1591
1592 class subliminal.providers.napiprojekt.NapiProjektProvider
1593 NapiProjekt Provider.
1594
1595 initialize()
1596 Initialize the provider.
1597
1598 Must be called when starting to work with the provider.
1599 This is the place for network initialization or login
1600 operations.
1601
1602 NOTE:
1603 This is called automatically when entering the with
1604 statement
1605
1606 terminate()
1607 Terminate the provider.
1608
1609 Must be called when done with the provider. This is the
1610 place for network shutdown or logout operations.
1611
1612 NOTE:
1613 This is called automatically when exiting the with
1614 statement
1615
1616 query(language, hash)
1617 Query the provider for subtitles.
1618
1619 Arguments should match as much as possible the actual
1620 parameters for querying the provider
1621
1622 Returns
1623 found subtitles.
1624
1625 Return type
1626 list of Subtitle
1627
1628 Raise ProviderError
1629
1630 list_subtitles(video, languages)
1631 List subtitles for the video with the given languages.
1632
1633 This will call the query() method internally. The parame‐
1634 ters passed to the query() method may vary depending on
1635 the amount of information available in the video.
1636
1637 Parameters
1638
1639 · video (Video) – video to list subtitles for.
1640
1641 · languages (set of Language) – languages to
1642 search for.
1643
1644 Returns
1645 found subtitles.
1646
1647 Return type
1648 list of Subtitle
1649
1650 Raise ProviderError
1651
1652 download_subtitle(subtitle)
1653 Download subtitle’s content.
1654
1655 Parameters
1656 subtitle (Subtitle) – subtitle to download.
1657
1658 Raise ProviderError
1659
1660 OpenSubtitles
1661 class subliminal.providers.opensubtitles.OpenSubtitlesSubtitle(lan‐
1662 guage, hearing_impaired, page_link, subtitle_id, matched_by,
1663 movie_kind, hash, movie_name, movie_release_name, movie_year,
1664 movie_imdb_id, series_season, series_episode, filename, encoding)
1665 OpenSubtitles Subtitle.
1666
1667 id Unique identifier of the subtitle
1668
1669 get_matches(video)
1670 Get the matches against the video.
1671
1672 Parameters
1673 video (Video) – the video to get the matches with.
1674
1675 Returns
1676 matches of the subtitle.
1677
1678 Return type
1679 set
1680
1681 class subliminal.providers.opensubtitles.OpenSubtitlesProvider(user‐
1682 name=None, password=None)
1683 OpenSubtitles Provider.
1684
1685 Parameters
1686
1687 · username (str) – username.
1688
1689 · password (str) – password.
1690
1691 initialize()
1692 Initialize the provider.
1693
1694 Must be called when starting to work with the provider.
1695 This is the place for network initialization or login
1696 operations.
1697
1698 NOTE:
1699 This is called automatically when entering the with
1700 statement
1701
1702 terminate()
1703 Terminate the provider.
1704
1705 Must be called when done with the provider. This is the
1706 place for network shutdown or logout operations.
1707
1708 NOTE:
1709 This is called automatically when exiting the with
1710 statement
1711
1712 query(languages, hash=None, size=None, imdb_id=None, query=None,
1713 season=None, episode=None, tag=None)
1714 Query the provider for subtitles.
1715
1716 Arguments should match as much as possible the actual
1717 parameters for querying the provider
1718
1719 Returns
1720 found subtitles.
1721
1722 Return type
1723 list of Subtitle
1724
1725 Raise ProviderError
1726
1727 list_subtitles(video, languages)
1728 List subtitles for the video with the given languages.
1729
1730 This will call the query() method internally. The parame‐
1731 ters passed to the query() method may vary depending on
1732 the amount of information available in the video.
1733
1734 Parameters
1735
1736 · video (Video) – video to list subtitles for.
1737
1738 · languages (set of Language) – languages to
1739 search for.
1740
1741 Returns
1742 found subtitles.
1743
1744 Return type
1745 list of Subtitle
1746
1747 Raise ProviderError
1748
1749 download_subtitle(subtitle)
1750 Download subtitle’s content.
1751
1752 Parameters
1753 subtitle (Subtitle) – subtitle to download.
1754
1755 Raise ProviderError
1756
1757 exception subliminal.providers.opensubtitles.OpenSubtitlesError
1758 Base class for non-generic OpenSubtitlesProvider exceptions.
1759
1760 exception subliminal.providers.opensubtitles.Unauthorized
1761 Exception raised when status is ‘401 Unauthorized’.
1762
1763 exception subliminal.providers.opensubtitles.NoSession
1764 Exception raised when status is ‘406 No session’.
1765
1766 exception subliminal.providers.opensubtitles.DownloadLimitReached
1767 Exception raised when status is ‘407 Download limit reached’.
1768
1769 exception subliminal.providers.opensubtitles.InvalidImdbid
1770 Exception raised when status is ‘413 Invalid ImdbID’.
1771
1772 exception subliminal.providers.opensubtitles.UnknownUserAgent
1773 Exception raised when status is ‘414 Unknown User Agent’.
1774
1775 exception subliminal.providers.opensubtitles.DisabledUserAgent
1776 Exception raised when status is ‘415 Disabled user agent’.
1777
1778 exception subliminal.providers.opensubtitles.ServiceUnavailable
1779 Exception raised when status is ‘503 Service Unavailable’.
1780
1781 subliminal.providers.opensubtitles.checked(response)
1782 Check a response status before returning it.
1783
1784 Parameters
1785 response – a response from a XMLRPC call to OpenSubti‐
1786 tles.
1787
1788 Returns
1789 the response.
1790
1791 Raise OpenSubtitlesError
1792
1793 Podnapisi
1794 class subliminal.providers.podnapisi.PodnapisiSubtitle(language, hear‐
1795 ing_impaired, page_link, pid, releases, title, season=None,
1796 episode=None, year=None)
1797 Podnapisi Subtitle.
1798
1799 id Unique identifier of the subtitle
1800
1801 get_matches(video)
1802 Get the matches against the video.
1803
1804 Parameters
1805 video (Video) – the video to get the matches with.
1806
1807 Returns
1808 matches of the subtitle.
1809
1810 Return type
1811 set
1812
1813 class subliminal.providers.podnapisi.PodnapisiProvider
1814 Podnapisi Provider.
1815
1816 initialize()
1817 Initialize the provider.
1818
1819 Must be called when starting to work with the provider.
1820 This is the place for network initialization or login
1821 operations.
1822
1823 NOTE:
1824 This is called automatically when entering the with
1825 statement
1826
1827 terminate()
1828 Terminate the provider.
1829
1830 Must be called when done with the provider. This is the
1831 place for network shutdown or logout operations.
1832
1833 NOTE:
1834 This is called automatically when exiting the with
1835 statement
1836
1837 query(language, keyword, season=None, episode=None, year=None)
1838 Query the provider for subtitles.
1839
1840 Arguments should match as much as possible the actual
1841 parameters for querying the provider
1842
1843 Returns
1844 found subtitles.
1845
1846 Return type
1847 list of Subtitle
1848
1849 Raise ProviderError
1850
1851 list_subtitles(video, languages)
1852 List subtitles for the video with the given languages.
1853
1854 This will call the query() method internally. The parame‐
1855 ters passed to the query() method may vary depending on
1856 the amount of information available in the video.
1857
1858 Parameters
1859
1860 · video (Video) – video to list subtitles for.
1861
1862 · languages (set of Language) – languages to
1863 search for.
1864
1865 Returns
1866 found subtitles.
1867
1868 Return type
1869 list of Subtitle
1870
1871 Raise ProviderError
1872
1873 download_subtitle(subtitle)
1874 Download subtitle’s content.
1875
1876 Parameters
1877 subtitle (Subtitle) – subtitle to download.
1878
1879 Raise ProviderError
1880
1881 Shooter
1882 class subliminal.providers.shooter.ShooterSubtitle(language, hash,
1883 download_link)
1884 Shooter Subtitle.
1885
1886 id Unique identifier of the subtitle
1887
1888 get_matches(video)
1889 Get the matches against the video.
1890
1891 Parameters
1892 video (Video) – the video to get the matches with.
1893
1894 Returns
1895 matches of the subtitle.
1896
1897 Return type
1898 set
1899
1900 class subliminal.providers.shooter.ShooterProvider
1901 Shooter Provider.
1902
1903 initialize()
1904 Initialize the provider.
1905
1906 Must be called when starting to work with the provider.
1907 This is the place for network initialization or login
1908 operations.
1909
1910 NOTE:
1911 This is called automatically when entering the with
1912 statement
1913
1914 terminate()
1915 Terminate the provider.
1916
1917 Must be called when done with the provider. This is the
1918 place for network shutdown or logout operations.
1919
1920 NOTE:
1921 This is called automatically when exiting the with
1922 statement
1923
1924 query(language, filename, hash=None)
1925 Query the provider for subtitles.
1926
1927 Arguments should match as much as possible the actual
1928 parameters for querying the provider
1929
1930 Returns
1931 found subtitles.
1932
1933 Return type
1934 list of Subtitle
1935
1936 Raise ProviderError
1937
1938 list_subtitles(video, languages)
1939 List subtitles for the video with the given languages.
1940
1941 This will call the query() method internally. The parame‐
1942 ters passed to the query() method may vary depending on
1943 the amount of information available in the video.
1944
1945 Parameters
1946
1947 · video (Video) – video to list subtitles for.
1948
1949 · languages (set of Language) – languages to
1950 search for.
1951
1952 Returns
1953 found subtitles.
1954
1955 Return type
1956 list of Subtitle
1957
1958 Raise ProviderError
1959
1960 download_subtitle(subtitle)
1961 Download subtitle’s content.
1962
1963 Parameters
1964 subtitle (Subtitle) – subtitle to download.
1965
1966 Raise ProviderError
1967
1968 SubsCenter
1969 class subliminal.providers.subscenter.SubsCenterSubtitle(language,
1970 hearing_impaired, page_link, series, season, episode, title, subti‐
1971 tle_id, subtitle_key, downloaded, releases)
1972 SubsCenter Subtitle.
1973
1974 id Unique identifier of the subtitle
1975
1976 get_matches(video)
1977 Get the matches against the video.
1978
1979 Parameters
1980 video (Video) – the video to get the matches with.
1981
1982 Returns
1983 matches of the subtitle.
1984
1985 Return type
1986 set
1987
1988 class subliminal.providers.subscenter.SubsCenterProvider(username=None,
1989 password=None)
1990 SubsCenter Provider.
1991
1992 initialize()
1993 Initialize the provider.
1994
1995 Must be called when starting to work with the provider.
1996 This is the place for network initialization or login
1997 operations.
1998
1999 NOTE:
2000 This is called automatically when entering the with
2001 statement
2002
2003 terminate()
2004 Terminate the provider.
2005
2006 Must be called when done with the provider. This is the
2007 place for network shutdown or logout operations.
2008
2009 NOTE:
2010 This is called automatically when exiting the with
2011 statement
2012
2013 _search_url_titles(title)
2014 Search the URL titles by kind for the given title.
2015
2016 Parameters
2017 title (str) – title to search for.
2018
2019 Returns
2020 the URL titles by kind.
2021
2022 Return type
2023 collections.defaultdict
2024
2025 query(title, season=None, episode=None)
2026 Query the provider for subtitles.
2027
2028 Arguments should match as much as possible the actual
2029 parameters for querying the provider
2030
2031 Returns
2032 found subtitles.
2033
2034 Return type
2035 list of Subtitle
2036
2037 Raise ProviderError
2038
2039 list_subtitles(video, languages)
2040 List subtitles for the video with the given languages.
2041
2042 This will call the query() method internally. The parame‐
2043 ters passed to the query() method may vary depending on
2044 the amount of information available in the video.
2045
2046 Parameters
2047
2048 · video (Video) – video to list subtitles for.
2049
2050 · languages (set of Language) – languages to
2051 search for.
2052
2053 Returns
2054 found subtitles.
2055
2056 Return type
2057 list of Subtitle
2058
2059 Raise ProviderError
2060
2061 download_subtitle(subtitle)
2062 Download subtitle’s content.
2063
2064 Parameters
2065 subtitle (Subtitle) – subtitle to download.
2066
2067 Raise ProviderError
2068
2069 TheSubDB
2070 class subliminal.providers.thesubdb.TheSubDBSubtitle(language, hash)
2071 TheSubDB Subtitle.
2072
2073 id Unique identifier of the subtitle
2074
2075 get_matches(video)
2076 Get the matches against the video.
2077
2078 Parameters
2079 video (Video) – the video to get the matches with.
2080
2081 Returns
2082 matches of the subtitle.
2083
2084 Return type
2085 set
2086
2087 class subliminal.providers.thesubdb.TheSubDBProvider
2088 TheSubDB Provider.
2089
2090 initialize()
2091 Initialize the provider.
2092
2093 Must be called when starting to work with the provider.
2094 This is the place for network initialization or login
2095 operations.
2096
2097 NOTE:
2098 This is called automatically when entering the with
2099 statement
2100
2101 terminate()
2102 Terminate the provider.
2103
2104 Must be called when done with the provider. This is the
2105 place for network shutdown or logout operations.
2106
2107 NOTE:
2108 This is called automatically when exiting the with
2109 statement
2110
2111 query(hash)
2112 Query the provider for subtitles.
2113
2114 Arguments should match as much as possible the actual
2115 parameters for querying the provider
2116
2117 Returns
2118 found subtitles.
2119
2120 Return type
2121 list of Subtitle
2122
2123 Raise ProviderError
2124
2125 list_subtitles(video, languages)
2126 List subtitles for the video with the given languages.
2127
2128 This will call the query() method internally. The parame‐
2129 ters passed to the query() method may vary depending on
2130 the amount of information available in the video.
2131
2132 Parameters
2133
2134 · video (Video) – video to list subtitles for.
2135
2136 · languages (set of Language) – languages to
2137 search for.
2138
2139 Returns
2140 found subtitles.
2141
2142 Return type
2143 list of Subtitle
2144
2145 Raise ProviderError
2146
2147 download_subtitle(subtitle)
2148 Download subtitle’s content.
2149
2150 Parameters
2151 subtitle (Subtitle) – subtitle to download.
2152
2153 Raise ProviderError
2154
2155 TVsubtitles
2156 class subliminal.providers.tvsubtitles.TVsubtitlesSubtitle(language,
2157 page_link, subtitle_id, series, season, episode, year, rip, release)
2158 TVsubtitles Subtitle.
2159
2160 id Unique identifier of the subtitle
2161
2162 get_matches(video)
2163 Get the matches against the video.
2164
2165 Parameters
2166 video (Video) – the video to get the matches with.
2167
2168 Returns
2169 matches of the subtitle.
2170
2171 Return type
2172 set
2173
2174 class subliminal.providers.tvsubtitles.TVsubtitlesProvider
2175 TVsubtitles Provider.
2176
2177 initialize()
2178 Initialize the provider.
2179
2180 Must be called when starting to work with the provider.
2181 This is the place for network initialization or login
2182 operations.
2183
2184 NOTE:
2185 This is called automatically when entering the with
2186 statement
2187
2188 terminate()
2189 Terminate the provider.
2190
2191 Must be called when done with the provider. This is the
2192 place for network shutdown or logout operations.
2193
2194 NOTE:
2195 This is called automatically when exiting the with
2196 statement
2197
2198 search_show_id(series, year=None)
2199 Search the show id from the series and year.
2200
2201 Parameters
2202
2203 · series (str) – series of the episode.
2204
2205 · year (int) – year of the series, if any.
2206
2207 Returns
2208 the show id, if any.
2209
2210 Return type
2211 int
2212
2213 get_episode_ids(show_id, season)
2214 Get episode ids from the show id and the season.
2215
2216 Parameters
2217
2218 · show_id (int) – show id.
2219
2220 · season (int) – season of the episode.
2221
2222 Returns
2223 episode ids per episode number.
2224
2225 Return type
2226 dict
2227
2228 query(series, season, episode, year=None)
2229 Query the provider for subtitles.
2230
2231 Arguments should match as much as possible the actual
2232 parameters for querying the provider
2233
2234 Returns
2235 found subtitles.
2236
2237 Return type
2238 list of Subtitle
2239
2240 Raise ProviderError
2241
2242 list_subtitles(video, languages)
2243 List subtitles for the video with the given languages.
2244
2245 This will call the query() method internally. The parame‐
2246 ters passed to the query() method may vary depending on
2247 the amount of information available in the video.
2248
2249 Parameters
2250
2251 · video (Video) – video to list subtitles for.
2252
2253 · languages (set of Language) – languages to
2254 search for.
2255
2256 Returns
2257 found subtitles.
2258
2259 Return type
2260 list of Subtitle
2261
2262 Raise ProviderError
2263
2264 download_subtitle(subtitle)
2265 Download subtitle’s content.
2266
2267 Parameters
2268 subtitle (Subtitle) – subtitle to download.
2269
2270 Raise ProviderError
2271
2272 Refiners
2273 Refiners enrich a Video object by adding information to it.
2274
2275 A refiner is a simple function:
2276
2277 subliminal.refiners.refine(video, **kwargs)
2278
2279 Parameters
2280
2281 · video (Video) – the video to refine.
2282
2283 · **kwargs – additional parameters for refiners.
2284
2285 Metadata
2286 subliminal.refiners.metadata.refine(video, embedded_subtitles=True,
2287 **kwargs)
2288 Refine a video by searching its metadata.
2289
2290 Several Video attributes can be found:
2291
2292 · resolution
2293
2294 · video_codec
2295
2296 · audio_codec
2297
2298 · subtitle_languages
2299
2300 Parameters
2301 embedded_subtitles (bool) – search for embedded subti‐
2302 tles.
2303
2304 TVDB
2305 subliminal.refiners.tvdb.refine(video, **kwargs)
2306 Refine a video by searching TheTVDB.
2307
2308 NOTE:
2309 This refiner only work for instances of Episode.
2310
2311 Several attributes can be found:
2312
2313 · series
2314
2315 · year
2316
2317 · series_imdb_id
2318
2319 · series_tvdb_id
2320
2321 · title
2322
2323 · imdb_id
2324
2325 · tvdb_id
2326
2327 OMDb
2328 subliminal.refiners.omdb.refine(video, **kwargs)
2329 Refine a video by searching OMDb API.
2330
2331 Several Episode attributes can be found:
2332
2333 · series
2334
2335 · year
2336
2337 · series_imdb_id
2338
2339 Similarly, for a Movie:
2340
2341 · title
2342
2343 · year
2344
2345 · imdb_id
2346
2347 Extensions
2348 class subliminal.extensions.RegistrableExtensionManager(namespace,
2349 internal_extensions, **kwargs)
2350 :class:~stevedore.extensions.ExtensionManager` with support for
2351 registration.
2352
2353 It allows loading of internal extensions without setup and reg‐
2354 istering/unregistering additional extensions.
2355
2356 Loading is done in this order:
2357
2358 · Entry point extensions
2359
2360 · Internal extensions
2361
2362 · Registered extensions
2363
2364 Parameters
2365
2366 · namespace (str) – namespace argument for :class:~steve‐
2367 dore.extensions.ExtensionManager`.
2368
2369 · internal_extensions (list) – internal extensions to use
2370 with entry point syntax.
2371
2372 · **kwargs – additional parameters for the :class:~steve‐
2373 dore.extensions.ExtensionManager` constructor.
2374
2375 registered_extensions = None
2376 Registered extensions with entry point syntax
2377
2378 internal_extensions = None
2379 Internal extensions with entry point syntax
2380
2381 register(entry_point)
2382 Register an extension
2383
2384 Parameters
2385 entry_point (str) – extension to register (entry
2386 point syntax).
2387
2388 Raise ValueError if already registered.
2389
2390 unregister(entry_point)
2391 Unregister a provider
2392
2393 Parameters
2394 entry_point (str) – provider to unregister (entry
2395 point syntax).
2396
2397 subliminal.extensions.provider_manager = <subliminal.extensions.Regis‐
2398 trableExtensionManager object>
2399 Provider manager
2400
2401 subliminal.extensions.refiner_manager = <subliminal.extensions.Regis‐
2402 trableExtensionManager object>
2403 Refiner manager
2404
2405 Score
2406 This module provides the default implementation of the compute_score
2407 parameter in download_best_subtitles() and download_best_subtitles().
2408
2409 NOTE:
2410 To avoid unnecessary dependency on sympy and boost subliminal’s
2411 import time, the resulting scores are hardcoded here and manually
2412 updated when the set of equations change.
2413
2414 Available matches:
2415
2416 · hash
2417
2418 · title
2419
2420 · year
2421
2422 · series
2423
2424 · season
2425
2426 · episode
2427
2428 · release_group
2429
2430 · format
2431
2432 · audio_codec
2433
2434 · resolution
2435
2436 · hearing_impaired
2437
2438 · video_codec
2439
2440 · series_imdb_id
2441
2442 · imdb_id
2443
2444 · tvdb_id
2445
2446 subliminal.score.episode_scores = {'audio_codec': 3, 'episode': 30,
2447 'format': 7, 'hash': 359, 'hearing_impaired': 1, 'release_group': 15,
2448 'resolution': 2, 'season': 30, 'series': 180, 'video_codec': 2, 'year':
2449 90}
2450 Scores for episodes
2451
2452 subliminal.score.movie_scores = {'audio_codec': 3, 'format': 7, 'hash':
2453 119, 'hearing_impaired': 1, 'release_group': 15, 'resolution': 2,
2454 'title': 60, 'video_codec': 2, 'year': 30}
2455 Scores for movies
2456
2457 subliminal.score.equivalent_release_groups = ({'LOL', 'DIMENSION'},
2458 {'IMMERSE', 'FLEET', 'ASAP'})
2459 Equivalent release groups
2460
2461 subliminal.score.get_equivalent_release_groups(release_group)
2462 Get all the equivalents of the given release group.
2463
2464 Parameters
2465 release_group (str) – the release group to get the equiv‐
2466 alents of.
2467
2468 Returns
2469 the equivalent release groups.
2470
2471 Return type
2472 set
2473
2474 subliminal.score.get_scores(video)
2475 Get the scores dict for the given video.
2476
2477 This will return either episode_scores or movie_scores based on
2478 the type of the video.
2479
2480 Parameters
2481 video (Video) – the video to compute the score against.
2482
2483 Returns
2484 the scores dict.
2485
2486 Return type
2487 dict
2488
2489 subliminal.score.compute_score(subtitle, video, hearing_impaired=None)
2490 Compute the score of the subtitle against the video with hear‐
2491 ing_impaired preference.
2492
2493 compute_score() uses the Subtitle.get_matches method and applies
2494 the scores (either from episode_scores or movie_scores) after
2495 some processing.
2496
2497 Parameters
2498
2499 · subtitle (Subtitle) – the subtitle to compute the score
2500 of.
2501
2502 · video (Video) – the video to compute the score against.
2503
2504 · hearing_impaired (bool) – hearing impaired preference.
2505
2506 Returns
2507 score of the subtitle.
2508
2509 Return type
2510 int
2511
2512 Utils
2513 subliminal.utils.hash_opensubtitles(video_path)
2514 Compute a hash using OpenSubtitles’ algorithm.
2515
2516 Parameters
2517 video_path (str) – path of the video.
2518
2519 Returns
2520 the hash.
2521
2522 Return type
2523 str
2524
2525 subliminal.utils.hash_thesubdb(video_path)
2526 Compute a hash using TheSubDB’s algorithm.
2527
2528 Parameters
2529 video_path (str) – path of the video.
2530
2531 Returns
2532 the hash.
2533
2534 Return type
2535 str
2536
2537 subliminal.utils.hash_napiprojekt(video_path)
2538 Compute a hash using NapiProjekt’s algorithm.
2539
2540 Parameters
2541 video_path (str) – path of the video.
2542
2543 Returns
2544 the hash.
2545
2546 Return type
2547 str
2548
2549 subliminal.utils.hash_shooter(video_path)
2550 Compute a hash using Shooter’s algorithm
2551
2552 Parameters
2553 video_path (string) – path of the video
2554
2555 Returns
2556 the hash
2557
2558 Return type
2559 string
2560
2561 subliminal.utils.sanitize(string, ignore_characters=None)
2562 Sanitize a string to strip special characters.
2563
2564 Parameters
2565
2566 · string (str) – the string to sanitize.
2567
2568 · ignore_characters (set) – characters to ignore.
2569
2570 Returns
2571 the sanitized string.
2572
2573 Return type
2574 str
2575
2576 subliminal.utils.sanitize_release_group(string)
2577 Sanitize a release_group string to remove content in square
2578 brackets.
2579
2580 Parameters
2581 string (str) – the release group to sanitize.
2582
2583 Returns
2584 the sanitized release group.
2585
2586 Return type
2587 str
2588
2589 subliminal.utils.timestamp(date)
2590 Get the timestamp of the date, python2/3 compatible
2591
2592 Parameters
2593 date (datetime.datetime) – the utc date.
2594
2595 Returns
2596 the timestamp of the date.
2597
2598 Return type
2599 float
2600
2601 Cache
2602 subliminal.cache.SHOW_EXPIRATION_TIME
2603 Expiration time for show caching
2604
2605 subliminal.cache.EPISODE_EXPIRATION_TIME
2606 Expiration time for episode caching
2607
2608 subliminal.cache.REFINER_EXPIRATION_TIME
2609 Expiration time for scraper searches
2610
2611 subliminal.cache.region
2612 The CacheRegion
2613
2614 Refer to dogpile.cache’s region configuration documentation to see how
2615 to configure the region
2616
2617 CLI
2618 Subliminal uses click to provide a powerful CLI.
2619
2620 class subliminal.cli.MutexLock(filename)
2621 MutexLock is a thread-based rw lock based on dogpile.core.Read‐
2622 WriteMutex.
2623
2624 acquire_read_lock(wait)
2625 Acquire a ‘reader’ lock.
2626
2627 Raises NotImplementedError by default, must be imple‐
2628 mented by subclasses.
2629
2630 acquire_write_lock(wait)
2631 Acquire a ‘write’ lock.
2632
2633 Raises NotImplementedError by default, must be imple‐
2634 mented by subclasses.
2635
2636 release_read_lock()
2637 Release a ‘reader’ lock.
2638
2639 Raises NotImplementedError by default, must be imple‐
2640 mented by subclasses.
2641
2642 release_write_lock()
2643 Release a ‘writer’ lock.
2644
2645 Raises NotImplementedError by default, must be imple‐
2646 mented by subclasses.
2647
2648 class subliminal.cli.Config(path)
2649 A ConfigParser wrapper to store configuration.
2650
2651 Interaction with the configuration is done with the properties.
2652
2653 Parameters
2654 path (str) – path to the configuration file.
2655
2656 path = None
2657 Path to the configuration file
2658
2659 config = None
2660 The underlying configuration object
2661
2662 read() Read the configuration from path
2663
2664 write()
2665 Write the configuration to path
2666
2667 class subliminal.cli.LanguageParamType
2668 ParamType for languages that returns a Language
2669
2670 convert(value, param, ctx)
2671 Converts the value. This is not invoked for values that
2672 are None (the missing value).
2673
2674 class subliminal.cli.AgeParamType
2675 ParamType for age strings that returns a timedelta
2676
2677 An age string is in the form number + identifier with possible
2678 identifiers:
2679
2680 · w for weeks
2681
2682 · d for days
2683
2684 · h for hours
2685
2686 The form can be specified multiple times but only with that
2687 idenfier ordering. For example:
2688
2689 · 1w2d4h for 1 week, 2 days and 4 hours
2690
2691 · 2w for 2 weeks
2692
2693 · 3w6h for 3 weeks and 6 hours
2694
2695 convert(value, param, ctx)
2696 Converts the value. This is not invoked for values that
2697 are None (the missing value).
2698
2699 Exceptions
2700 exception subliminal.exceptions.Error
2701 Base class for exceptions in subliminal.
2702
2703 exception subliminal.exceptions.ProviderError
2704 Exception raised by providers.
2705
2706 exception subliminal.exceptions.ConfigurationError
2707 Exception raised by providers when badly configured.
2708
2709 exception subliminal.exceptions.AuthenticationError
2710 Exception raised by providers when authentication failed.
2711
2712 exception subliminal.exceptions.TooManyRequests
2713 Exception raised by providers when too many requests are made.
2714
2715 exception subliminal.exceptions.DownloadLimitExceeded
2716 Exception raised by providers when download limit is exceeded.
2717
2719 MIT
2720
2721 · genindex
2722
2723 · modindex
2724
2725 · search
2726
2728 Antoine Bertin
2729
2731 2016, Antoine Bertin
2732
2733
2734
2735
27362.0.5 Feb 02, 2019 SUBLIMINAL(1)