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 Traceback (most recent call last):
228 File "/builddir/build/BUILDROOT/python-subliminal-2.0.5-8.fc29.noarch/usr/bin/subliminal", line 6, in <module>
229 from pkg_resources import load_entry_point
230 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3112, in <module>
231 @_call_aside
232 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3096, in _call_aside
233 f(*args, **kwargs)
234 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3125, in _initialize_master_working_set
235 working_set = WorkingSet._build_master()
236 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 578, in _build_master
237 ws.require(__requires__)
238 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 895, in require
239 needed = self.resolve(parse_requirements(requirements))
240 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 781, in resolve
241 raise DistributionNotFound(req, requirers)
242 pkg_resources.DistributionNotFound: The 'pytz>=2012c' distribution was not found and is required by subliminal
243
244 subliminal download
245 Traceback (most recent call last):
246 File "/builddir/build/BUILDROOT/python-subliminal-2.0.5-8.fc29.noarch/usr/bin/subliminal", line 6, in <module>
247 from pkg_resources import load_entry_point
248 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3112, in <module>
249 @_call_aside
250 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3096, in _call_aside
251 f(*args, **kwargs)
252 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3125, in _initialize_master_working_set
253 working_set = WorkingSet._build_master()
254 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 578, in _build_master
255 ws.require(__requires__)
256 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 895, in require
257 needed = self.resolve(parse_requirements(requirements))
258 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 781, in resolve
259 raise DistributionNotFound(req, requirers)
260 pkg_resources.DistributionNotFound: The 'pytz>=2012c' distribution was not found and is required by subliminal
261
262 subliminal cache
263 Traceback (most recent call last):
264 File "/builddir/build/BUILDROOT/python-subliminal-2.0.5-8.fc29.noarch/usr/bin/subliminal", line 6, in <module>
265 from pkg_resources import load_entry_point
266 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3112, in <module>
267 @_call_aside
268 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3096, in _call_aside
269 f(*args, **kwargs)
270 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3125, in _initialize_master_working_set
271 working_set = WorkingSet._build_master()
272 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 578, in _build_master
273 ws.require(__requires__)
274 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 895, in require
275 needed = self.resolve(parse_requirements(requirements))
276 File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 781, in resolve
277 raise DistributionNotFound(req, requirers)
278 pkg_resources.DistributionNotFound: The 'pytz>=2012c' distribution was not found and is required by subliminal
279
280 Provider Guide
281 This guide is going to explain how to add a Provider to subliminal. You
282 are encouraged to take a look at the existing providers, it can be a
283 nice base to start your own provider.
284
285 Requirements
286 When starting a provider you should be able to answer to the following
287 questions:
288
289 · What languages does my provider support?
290
291 · What are the language codes for the supported languages?
292
293 · Does my provider deliver subtitles for episodes? for movies?
294
295 · Does my provider require a video hash?
296
297 Each response of these questions will help you set the correct
298 attributes for your Provider.
299
300 Video Validation
301 Not all providers deliver subtitles for Episode. Some may require a
302 hash. The check() method does validation against a Video object and
303 will return False if the given Video isn’t suitable. If you’re not
304 happy with the default implementation, you can override it.
305
306 Configuration
307 API keys must not be configurable by the user and must remain linked to
308 subliminal. Hence they must be written in the provider module.
309
310 Per-user authentication is allowed and must be configured at instantia‐
311 tion as keyword arguments. Configuration will be done by the user
312 through the provider_configs argument of the list_subtitles() and down‐
313 load_best_subtitles() functions. No network operation must be done dur‐
314 ing instantiation, only configuration. Any error in the configuration
315 must raise a ConfigurationError.
316
317 Beyond this point, if an error occurs, a generic ProviderError excep‐
318 tion must be raised. You can also use more explicit exception classes
319 AuthenticationError and DownloadLimitExceeded.
320
321 Initialization / Termination
322 Actual authentication operations must take place in the initialize()
323 method. If you need anything to be executed when the provider isn’t
324 used anymore like logout, use terminate().
325
326 Caching policy
327 To save bandwidth and improve querying time, intermediate data should
328 be cached when possible. Typical use case is when a query to retrieve
329 show ids is required prior to the query to actually search for subti‐
330 tles. In that case the function that gets the show id from the show
331 name must be cached. Expiration time should be SHOW_EXPIRATION_TIME
332 for shows and EPISODE_EXPIRATION_TIME for episodes.
333
334 Language
335 To be able to handle various language codes, subliminal makes use of
336 babelfish Language and converters. You must set the attribute languages
337 with a set of supported Language.
338
339 If you cannot find a suitable converter for your provider, you can make
340 one of your own.
341
342 Querying
343 The query() method parameters must include all aspects of provider’s
344 querying with primary types.
345
346 Subtitle
347 A custom Subtitle subclass must be created to represent a subtitle from
348 the provider. It must have relevant attributes that can be used to
349 compute the matches of the subtitle against a Video object.
350
351 Score computation
352 To be able to compare subtitles coming from different providers between
353 them, the get_matches() method must be implemented.
354
355 Unittesting
356 All possible uses of query(), list_subtitles() and download_subtitle()
357 methods must have integration tests. Use vcrpy for recording and play‐
358 back of network activity. Other functions must be unittested. If nec‐
359 essary, you can use unittest.mock to mock some functions.
360
362 If you are looking for information on a specific function, class or
363 method, this part of the documentation is for you.
364
365 Core
366 subliminal.core.ARCHIVE_EXTENSIONS
367 Supported archive extensions
368
369 class subliminal.core.ProviderPool(providers=None, provider_con‐
370 figs=None)
371 A pool of providers with the same API as a single Provider.
372
373 It has a few extra features:
374
375 · Lazy loads providers when needed and supports the with
376 statement to terminate() the providers on exit.
377
378 · Automatically discard providers on failure.
379
380 Parameters
381
382 · providers (list) – name of providers to use, if not
383 all.
384
385 · provider_configs (dict) – provider configuration as
386 keyword arguments per provider name to pass when
387 instanciating the Provider.
388
389 providers = None
390 Name of providers to use
391
392 provider_configs = None
393 Provider configuration
394
395 initialized_providers = None
396 Initialized providers
397
398 discarded_providers = None
399 Discarded providers
400
401 list_subtitles_provider(provider, video, languages)
402 List subtitles with a single provider.
403
404 The video and languages are checked against the provider.
405
406 Parameters
407
408 · provider (str) – name of the provider.
409
410 · video (Video) – video to list subtitles for.
411
412 · languages (set of Language) – languages to
413 search for.
414
415 Returns
416 found subtitles.
417
418 Return type
419 list of Subtitle or None
420
421 list_subtitles(video, languages)
422 List subtitles.
423
424 Parameters
425
426 · video (Video) – video to list subtitles for.
427
428 · languages (set of Language) – languages to
429 search for.
430
431 Returns
432 found subtitles.
433
434 Return type
435 list of Subtitle
436
437 download_subtitle(subtitle)
438 Download subtitle’s content.
439
440 Parameters
441 subtitle (Subtitle) – subtitle to download.
442
443 Returns
444 True if the subtitle has been successfully down‐
445 loaded, False otherwise.
446
447 Return type
448 bool
449
450 download_best_subtitles(subtitles, video, languages,
451 min_score=0, hearing_impaired=False, only_one=False, com‐
452 pute_score=None)
453 Download the best matching subtitles.
454
455 Parameters
456
457 · subtitles (list of Subtitle) – the subtitles to
458 use.
459
460 · video (Video) – video to download subtitles for.
461
462 · languages (set of Language) – languages to down‐
463 load.
464
465 · min_score (int) – minimum score for a subtitle
466 to be downloaded.
467
468 · hearing_impaired (bool) – hearing impaired pref‐
469 erence.
470
471 · only_one (bool) – download only one subtitle,
472 not one per language.
473
474 · compute_score – function that takes subtitle and
475 video as positional arguments, hearing_impaired
476 as keyword argument and returns the score.
477
478 Returns
479 downloaded subtitles.
480
481 Return type
482 list of Subtitle
483
484 terminate()
485 Terminate all the initialized_providers.
486
487 class subliminal.core.AsyncProviderPool(max_workers=None, *args,
488 **kwargs)
489 Subclass of ProviderPool with asynchronous support for
490 list_subtitles().
491
492 Parameters
493 max_workers (int) – maximum number of threads to use. If
494 None, max_workers will be set to the number of providers.
495
496 max_workers = None
497 Maximum number of threads to use
498
499 list_subtitles_provider(provider, video, languages)
500 List subtitles with a single provider.
501
502 The video and languages are checked against the provider.
503
504 Parameters
505
506 · provider (str) – name of the provider.
507
508 · video (Video) – video to list subtitles for.
509
510 · languages (set of Language) – languages to
511 search for.
512
513 Returns
514 found subtitles.
515
516 Return type
517 list of Subtitle or None
518
519 list_subtitles(video, languages)
520 List subtitles.
521
522 Parameters
523
524 · video (Video) – video to list subtitles for.
525
526 · languages (set of Language) – languages to
527 search for.
528
529 Returns
530 found subtitles.
531
532 Return type
533 list of Subtitle
534
535 subliminal.core.check_video(video, languages=None, age=None, unde‐
536 fined=False)
537 Perform some checks on the video.
538
539 All the checks are optional. Return False if any of this check
540 fails:
541
542 · languages already exist in video’s subtitle_languages.
543
544 · video is older than age.
545
546 · video has an undefined language in subtitle_languages.
547
548 Parameters
549
550 · video (Video) – video to check.
551
552 · languages (set of Language) – desired languages.
553
554 · age (datetime.timedelta) – maximum age of the video.
555
556 · undefined (bool) – fail on existing undefined language.
557
558 Returns
559 True if the video passes the checks, False otherwise.
560
561 Return type
562 bool
563
564 subliminal.core.search_external_subtitles(path, directory=None)
565 Search for external subtitles from a video path and their asso‐
566 ciated language.
567
568 Unless directory is provided, search will be made in the same
569 directory as the video file.
570
571 Parameters
572
573 · path (str) – path to the video.
574
575 · directory (str) – directory to search for subtitles.
576
577 Returns
578 found subtitles with their languages.
579
580 Return type
581 dict
582
583 subliminal.core.scan_video(path)
584 Scan a video from a path.
585
586 Parameters
587 path (str) – existing path to the video.
588
589 Returns
590 the scanned video.
591
592 Return type
593 Video
594
595 subliminal.core.scan_archive(path)
596 Scan an archive from a path.
597
598 Parameters
599 path (str) – existing path to the archive.
600
601 Returns
602 the scanned video.
603
604 Return type
605 Video
606
607 subliminal.core.scan_videos(path, age=None, archives=True)
608 Scan path for videos and their subtitles.
609
610 See refine() to find additional information for the video.
611
612 Parameters
613
614 · path (str) – existing directory path to scan.
615
616 · age (datetime.timedelta) – maximum age of the video or
617 archive.
618
619 · archives (bool) – scan videos in archives.
620
621 Returns
622 the scanned videos.
623
624 Return type
625 list of Video
626
627 subliminal.core.refine(video, episode_refiners=None, movie_refin‐
628 ers=None, **kwargs)
629 Refine a video using refiners.
630
631 NOTE:
632 Exceptions raised in refiners are silently passed and logged.
633
634 Parameters
635
636 · video (Video) – the video to refine.
637
638 · episode_refiners (tuple) – refiners to use for
639 episodes.
640
641 · movie_refiners (tuple) – refiners to use for movies.
642
643 · **kwargs – additional parameters for the refine() func‐
644 tions.
645
646 subliminal.core.list_subtitles(videos, languages, pool_class=<class
647 'subliminal.core.ProviderPool'>, **kwargs)
648 List subtitles.
649
650 The videos must pass the languages check of check_video().
651
652 Parameters
653
654 · videos (set of Video) – videos to list subtitles for.
655
656 · languages (set of Language) – languages to search for.
657
658 · pool_class (ProviderPool, AsyncProviderPool or similar)
659 – class to use as provider pool.
660
661 · **kwargs – additional parameters for the provided
662 pool_class constructor.
663
664 Returns
665 found subtitles per video.
666
667 Return type
668 dict of Video to list of Subtitle
669
670 subliminal.core.download_subtitles(subtitles, pool_class=<class 'sub‐
671 liminal.core.ProviderPool'>, **kwargs)
672 Download content of subtitles.
673
674 Parameters
675
676 · subtitles (list of Subtitle) – subtitles to download.
677
678 · pool_class (ProviderPool, AsyncProviderPool or similar)
679 – class to use as provider pool.
680
681 · **kwargs – additional parameters for the provided
682 pool_class constructor.
683
684 subliminal.core.download_best_subtitles(videos, languages, min_score=0,
685 hearing_impaired=False, only_one=False, compute_score=None,
686 pool_class=<class 'subliminal.core.ProviderPool'>, **kwargs)
687 List and download the best matching subtitles.
688
689 The videos must pass the languages and undefined (only_one)
690 checks of check_video().
691
692 Parameters
693
694 · videos (set of Video) – videos to download subtitles
695 for.
696
697 · languages (set of Language) – languages to download.
698
699 · min_score (int) – minimum score for a subtitle to be
700 downloaded.
701
702 · hearing_impaired (bool) – hearing impaired preference.
703
704 · only_one (bool) – download only one subtitle, not one
705 per language.
706
707 · compute_score – function that takes subtitle and video
708 as positional arguments, hearing_impaired as keyword
709 argument and returns the score.
710
711 · pool_class (ProviderPool, AsyncProviderPool or similar)
712 – class to use as provider pool.
713
714 · **kwargs – additional parameters for the provided
715 pool_class constructor.
716
717 Returns
718 downloaded subtitles per video.
719
720 Return type
721 dict of Video to list of Subtitle
722
723 subliminal.core.save_subtitles(video, subtitles, single=False, direc‐
724 tory=None, encoding=None)
725 Save subtitles on filesystem.
726
727 Subtitles are saved in the order of the list. If a subtitle with
728 a language has already been saved, other subtitles with the same
729 language are silently ignored.
730
731 The extension used is .lang.srt by default or .srt is single is
732 True, with lang being the IETF code for the language of the sub‐
733 title.
734
735 Parameters
736
737 · video (Video) – video of the subtitles.
738
739 · subtitles (list of Subtitle) – subtitles to save.
740
741 · single (bool) – save a single subtitle, default is to
742 save one subtitle per language.
743
744 · directory (str) – path to directory where to save the
745 subtitles, default is next to the video.
746
747 · encoding (str) – encoding in which to save the subti‐
748 tles, default is to keep original encoding.
749
750 Returns
751 the saved subtitles
752
753 Return type
754 list of Subtitle
755
756 Video
757 subliminal.video.VIDEO_EXTENSIONS
758 Video extensions
759
760 class subliminal.video.Video(name, format=None, release_group=None,
761 resolution=None, video_codec=None, audio_codec=None, imdb_id=None,
762 hashes=None, size=None, subtitle_languages=None)
763 Base class for videos.
764
765 Represent a video, existing or not.
766
767 Parameters
768
769 · name (str) – name or path of the video.
770
771 · format (str) – format of the video (HDTV, WEB-DL, Blu‐
772 Ray, …).
773
774 · release_group (str) – release group of the video.
775
776 · resolution (str) – resolution of the video stream
777 (480p, 720p, 1080p or 1080i).
778
779 · video_codec (str) – codec of the video stream.
780
781 · audio_codec (str) – codec of the main audio stream.
782
783 · imdb_id (str) – IMDb id of the video.
784
785 · hashes (dict) – hashes of the video file by provider
786 names.
787
788 · size (int) – size of the video file in bytes.
789
790 · subtitle_languages (set) – existing subtitle languages.
791
792 name = None
793 Name or path of the video
794
795 format = None
796 Format of the video (HDTV, WEB-DL, BluRay, …)
797
798 release_group = None
799 Release group of the video
800
801 resolution = None
802 Resolution of the video stream (480p, 720p, 1080p or
803 1080i)
804
805 video_codec = None
806 Codec of the video stream
807
808 audio_codec = None
809 Codec of the main audio stream
810
811 imdb_id = None
812 IMDb id of the video
813
814 hashes = None
815 Hashes of the video file by provider names
816
817 size = None
818 Size of the video file in bytes
819
820 subtitle_languages = None
821 Existing subtitle languages
822
823 exists Test whether the video exists
824
825 age Age of the video
826
827 classmethod fromguess(name, guess)
828 Create an Episode or a Movie with the given name based on
829 the guess.
830
831 Parameters
832
833 · name (str) – name of the video.
834
835 · guess (dict) – guessed data.
836
837 Raise ValueError if the type of the guess is invalid
838
839 classmethod fromname(name)
840 Shortcut for fromguess() with a guess guessed from the
841 name.
842
843 Parameters
844 name (str) – name of the video.
845
846 class subliminal.video.Episode(name, series, season, episode,
847 title=None, year=None, original_series=True, tvdb_id=None,
848 series_tvdb_id=None, series_imdb_id=None, **kwargs)
849 Episode Video.
850
851 Parameters
852
853 · series (str) – series of the episode.
854
855 · season (int) – season number of the episode.
856
857 · episode (int) – episode number of the episode.
858
859 · title (str) – title of the episode.
860
861 · year (int) – year of the series.
862
863 · original_series (bool) – whether the series is the
864 first with this name.
865
866 · tvdb_id (int) – TVDB id of the episode.
867
868 · **kwargs – additional parameters for the Video con‐
869 structor.
870
871 series = None
872 Series of the episode
873
874 season = None
875 Season number of the episode
876
877 episode = None
878 Episode number of the episode
879
880 title = None
881 Title of the episode
882
883 year = None
884 Year of series
885
886 original_series = None
887 The series is the first with this name
888
889 tvdb_id = None
890 TVDB id of the episode
891
892 series_tvdb_id = None
893 TVDB id of the series
894
895 series_imdb_id = None
896 IMDb id of the series
897
898 classmethod fromguess(name, guess)
899 Create an Episode or a Movie with the given name based on
900 the guess.
901
902 Parameters
903
904 · name (str) – name of the video.
905
906 · guess (dict) – guessed data.
907
908 Raise ValueError if the type of the guess is invalid
909
910 classmethod fromname(name)
911 Shortcut for fromguess() with a guess guessed from the
912 name.
913
914 Parameters
915 name (str) – name of the video.
916
917 class subliminal.video.Movie(name, title, year=None, **kwargs)
918 Movie Video.
919
920 Parameters
921
922 · title (str) – title of the movie.
923
924 · year (int) – year of the movie.
925
926 · **kwargs – additional parameters for the Video con‐
927 structor.
928
929 title = None
930 Title of the movie
931
932 year = None
933 Year of the movie
934
935 classmethod fromguess(name, guess)
936 Create an Episode or a Movie with the given name based on
937 the guess.
938
939 Parameters
940
941 · name (str) – name of the video.
942
943 · guess (dict) – guessed data.
944
945 Raise ValueError if the type of the guess is invalid
946
947 classmethod fromname(name)
948 Shortcut for fromguess() with a guess guessed from the
949 name.
950
951 Parameters
952 name (str) – name of the video.
953
954 Subtitle
955 subliminal.subtitle.SUBTITLE_EXTENSIONS
956 Subtitle extensions
957
958 class subliminal.subtitle.Subtitle(language, hearing_impaired=False,
959 page_link=None, encoding=None)
960 Base class for subtitle.
961
962 Parameters
963
964 · language (Language) – language of the subtitle.
965
966 · hearing_impaired (bool) – whether or not the subtitle
967 is hearing impaired.
968
969 · page_link (str) – URL of the web page from which the
970 subtitle can be downloaded.
971
972 · encoding (str) – Text encoding of the subtitle.
973
974 provider_name = ''
975 Name of the provider that returns that class of subtitle
976
977 language = None
978 Language of the subtitle
979
980 hearing_impaired = None
981 Whether or not the subtitle is hearing impaired
982
983 page_link = None
984 URL of the web page from which the subtitle can be down‐
985 loaded
986
987 content = None
988 Content as bytes
989
990 encoding = None
991 Encoding to decode with when accessing text
992
993 id Unique identifier of the subtitle
994
995 text Content as string
996
997 If encoding is None, the encoding is guessed with
998 guess_encoding()
999
1000 is_valid()
1001 Check if a text is a valid SubRip format.
1002
1003 Returns
1004 whether or not the subtitle is valid.
1005
1006 Return type
1007 bool
1008
1009 guess_encoding()
1010 Guess encoding using the language, falling back on
1011 chardet.
1012
1013 Returns
1014 the guessed encoding.
1015
1016 Return type
1017 str
1018
1019 get_matches(video)
1020 Get the matches against the video.
1021
1022 Parameters
1023 video (Video) – the video to get the matches with.
1024
1025 Returns
1026 matches of the subtitle.
1027
1028 Return type
1029 set
1030
1031 subliminal.subtitle.get_subtitle_path(video_path, language=None, exten‐
1032 sion='.srt')
1033 Get the subtitle path using the video_path and language.
1034
1035 Parameters
1036
1037 · video_path (str) – path to the video.
1038
1039 · language (Language) – language of the subtitle to put
1040 in the path.
1041
1042 · extension (str) – extension of the subtitle.
1043
1044 Returns
1045 path of the subtitle.
1046
1047 Return type
1048 str
1049
1050 subliminal.subtitle.guess_matches(video, guess, partial=False)
1051 Get matches between a video and a guess.
1052
1053 If a guess is partial, the absence information won’t be counted
1054 as a match.
1055
1056 Parameters
1057
1058 · video (Video) – the video.
1059
1060 · guess (dict) – the guess.
1061
1062 · partial (bool) – whether or not the guess is partial.
1063
1064 Returns
1065 matches between the video and the guess.
1066
1067 Return type
1068 set
1069
1070 subliminal.subtitle.fix_line_ending(content)
1071 Fix line ending of content by changing it to
1072
1073 param bytes content
1074 content of the subtitle.
1075
1076 return the content with fixed line endings.
1077
1078 rtype bytes
1079
1080 Providers
1081 class subliminal.providers.TimeoutSafeTransport(timeout, *args,
1082 **kwargs)
1083 Timeout support for xmlrpc.client.SafeTransport.
1084
1085 class subliminal.providers.ParserBeautifulSoup(markup, parsers,
1086 **kwargs)
1087 A bs4.BeautifulSoup that picks the first parser available in
1088 parsers.
1089
1090 Parameters
1091
1092 · markup -- markup for the bs4.BeautifulSoup.
1093
1094 · parsers (list) -- parser names, in order of preference.
1095
1096 class subliminal.providers.Provider
1097 Base class for providers.
1098
1099 If any configuration is possible for the provider, like creden‐
1100 tials, it must take place during instantiation.
1101
1102 Raise ConfigurationError if there is a configuration error
1103
1104 languages = set([])
1105 Supported set of Language
1106
1107 video_types = (<class 'subliminal.video.Episode'>, <class 'sub‐
1108 liminal.video.Movie'>)
1109 Supported video types
1110
1111 required_hash = None
1112 Required hash, if any
1113
1114 initialize()
1115 Initialize the provider.
1116
1117 Must be called when starting to work with the provider.
1118 This is the place for network initialization or login
1119 operations.
1120
1121 NOTE:
1122 This is called automatically when entering the with
1123 statement
1124
1125 terminate()
1126 Terminate the provider.
1127
1128 Must be called when done with the provider. This is the
1129 place for network shutdown or logout operations.
1130
1131 NOTE:
1132 This is called automatically when exiting the with
1133 statement
1134
1135 classmethod check(video)
1136 Check if the video can be processed.
1137
1138 The video is considered invalid if not an instance of
1139 video_types or if the required_hash is not present in
1140 hashes attribute of the video.
1141
1142 Parameters
1143 video (Video) -- the video to check.
1144
1145 Returns
1146 True if the video is valid, False otherwise.
1147
1148 Return type
1149 bool
1150
1151 query(*args, **kwargs)
1152 Query the provider for subtitles.
1153
1154 Arguments should match as much as possible the actual
1155 parameters for querying the provider
1156
1157 Returns
1158 found subtitles.
1159
1160 Return type
1161 list of Subtitle
1162
1163 Raise ProviderError
1164
1165 list_subtitles(video, languages)
1166 List subtitles for the video with the given languages.
1167
1168 This will call the query() method internally. The parame‐
1169 ters passed to the query() method may vary depending on
1170 the amount of information available in the video.
1171
1172 Parameters
1173
1174 · video (Video) -- video to list subtitles for.
1175
1176 · languages (set of Language) -- languages to
1177 search for.
1178
1179 Returns
1180 found subtitles.
1181
1182 Return type
1183 list of Subtitle
1184
1185 Raise ProviderError
1186
1187 download_subtitle(subtitle)
1188 Download subtitle's content.
1189
1190 Parameters
1191 subtitle (Subtitle) -- subtitle to download.
1192
1193 Raise ProviderError
1194
1195 Addic7ed
1196 subliminal.providers.addic7ed.series_year_re = <_sre.SRE_Pattern
1197 object>
1198 Series header parsing regex
1199
1200 class subliminal.providers.addic7ed.Addic7edSubtitle(language, hear‐
1201 ing_impaired, page_link, series, season, episode, title, year, version,
1202 download_link)
1203 Addic7ed Subtitle.
1204
1205 get_matches(video)
1206 Get the matches against the video.
1207
1208 Parameters
1209 video (Video) -- the video to get the matches
1210 with.
1211
1212 Returns
1213 matches of the subtitle.
1214
1215 Return type
1216 set
1217
1218 class subliminal.providers.addic7ed.Addic7edProvider(username=None,
1219 password=None)
1220 Addic7ed Provider.
1221
1222 initialize()
1223 Initialize the provider.
1224
1225 Must be called when starting to work with the provider.
1226 This is the place for network initialization or login
1227 operations.
1228
1229 NOTE:
1230 This is called automatically when entering the with
1231 statement
1232
1233 terminate()
1234 Terminate the provider.
1235
1236 Must be called when done with the provider. This is the
1237 place for network shutdown or logout operations.
1238
1239 NOTE:
1240 This is called automatically when exiting the with
1241 statement
1242
1243 _get_show_ids(**kw)
1244 Get the dict of show ids per series by querying the
1245 shows.php page.
1246
1247 Returns
1248 show id per series, lower case and without quotes.
1249
1250 Return type
1251 dict
1252
1253 _search_show_id(**kw)
1254 Search the show id from the series and year.
1255
1256 Parameters
1257
1258 · series (str) -- series of the episode.
1259
1260 · year (int) -- year of the series, if any.
1261
1262 Returns
1263 the show id, if found.
1264
1265 Return type
1266 int
1267
1268 get_show_id(series, year=None, country_code=None)
1269 Get the best matching show id for series, year and coun‐
1270 try_code.
1271
1272 First search in the result of _get_show_ids() and fall‐
1273 back on a search with _search_show_id().
1274
1275 Parameters
1276
1277 · series (str) -- series of the episode.
1278
1279 · year (int) -- year of the series, if any.
1280
1281 · country_code (str) -- country code of the
1282 series, if any.
1283
1284 Returns
1285 the show id, if found.
1286
1287 Return type
1288 int
1289
1290 query(series, season, year=None, country=None)
1291 Query the provider for subtitles.
1292
1293 Arguments should match as much as possible the actual
1294 parameters for querying the provider
1295
1296 Returns
1297 found subtitles.
1298
1299 Return type
1300 list of Subtitle
1301
1302 Raise ProviderError
1303
1304 list_subtitles(video, languages)
1305 List subtitles for the video with the given languages.
1306
1307 This will call the query() method internally. The parame‐
1308 ters passed to the query() method may vary depending on
1309 the amount of information available in the video.
1310
1311 Parameters
1312
1313 · video (Video) -- video to list subtitles for.
1314
1315 · languages (set of Language) -- languages to
1316 search for.
1317
1318 Returns
1319 found subtitles.
1320
1321 Return type
1322 list of Subtitle
1323
1324 Raise ProviderError
1325
1326 download_subtitle(subtitle)
1327 Download subtitle's content.
1328
1329 Parameters
1330 subtitle (Subtitle) -- subtitle to download.
1331
1332 Raise ProviderError
1333
1334 LegendasTv
1335 subliminal.providers.legendastv.type_map = {'C': 'episode', 'M':
1336 'movie', 'S': 'episode'}
1337 Conversion map for types
1338
1339 subliminal.providers.legendastv.season_re = <_sre.SRE_Pattern object>
1340 BR title season parsing regex
1341
1342 subliminal.providers.legendastv.downloads_re = <_sre.SRE_Pattern
1343 object>
1344 Downloads parsing regex
1345
1346 subliminal.providers.legendastv.rating_re = <_sre.SRE_Pattern object>
1347 Rating parsing regex
1348
1349 subliminal.providers.legendastv.timestamp_re = <_sre.SRE_Pattern
1350 object>
1351 Timestamp parsing regex
1352
1353 subliminal.providers.legendastv.releases_key = 'sublimi‐
1354 nal.providers.legendastv:releases|{archive_id}'
1355 Cache key for releases
1356
1357 class subliminal.providers.legendastv.LegendasTVArchive(id, name, pack,
1358 featured, link, downloads=0, rating=0, timestamp=None)
1359 LegendasTV Archive.
1360
1361 Parameters
1362
1363 · id (str) -- identifier.
1364
1365 · name (str) -- name.
1366
1367 · pack (bool) -- contains subtitles for multiple
1368 episodes.
1369
1370 · pack -- featured.
1371
1372 · link (str) -- link.
1373
1374 · downloads (int) -- download count.
1375
1376 · rating (int) -- rating (0-10).
1377
1378 · timestamp (datetime.datetime) -- timestamp.
1379
1380 id = None
1381 Identifier
1382
1383 name = None
1384 Name
1385
1386 pack = None
1387 Pack
1388
1389 featured = None
1390 Featured
1391
1392 link = None
1393 Link
1394
1395 downloads = None
1396 Download count
1397
1398 rating = None
1399 Rating (0-10)
1400
1401 timestamp = None
1402 Timestamp
1403
1404 content = None
1405 Compressed content as rarfile.RarFile or zipfile.ZipFile
1406
1407 class subliminal.providers.legendastv.LegendasTVSubtitle(language,
1408 type, title, year, imdb_id, season, archive, name)
1409 LegendasTV Subtitle.
1410
1411 get_matches(video, hearing_impaired=False)
1412 Get the matches against the video.
1413
1414 Parameters
1415 video (Video) -- the video to get the matches
1416 with.
1417
1418 Returns
1419 matches of the subtitle.
1420
1421 Return type
1422 set
1423
1424 class subliminal.providers.legendastv.LegendasTVProvider(username=None,
1425 password=None)
1426 LegendasTV Provider.
1427
1428 Parameters
1429
1430 · username (str) -- username.
1431
1432 · password (str) -- password.
1433
1434 initialize()
1435 Initialize the provider.
1436
1437 Must be called when starting to work with the provider.
1438 This is the place for network initialization or login
1439 operations.
1440
1441 NOTE:
1442 This is called automatically when entering the with
1443 statement
1444
1445 terminate()
1446 Terminate the provider.
1447
1448 Must be called when done with the provider. This is the
1449 place for network shutdown or logout operations.
1450
1451 NOTE:
1452 This is called automatically when exiting the with
1453 statement
1454
1455 search_titles(**kw)
1456 Search for titles matching the title.
1457
1458 Parameters
1459 title (str) -- the title to search for.
1460
1461 Returns
1462 found titles.
1463
1464 Return type
1465 dict
1466
1467 get_archives(**kw)
1468 Get the archive list from a given title_id and lan‐
1469 guage_code.
1470
1471 Parameters
1472
1473 · title_id (int) -- title id.
1474
1475 · language_code (int) -- language code.
1476
1477 Returns
1478 the archives.
1479
1480 Return type
1481 list of LegendasTVArchive
1482
1483 download_archive(archive)
1484 Download an archive's content.
1485
1486 Parameters
1487 archive (LegendasTVArchive) -- the archive to
1488 download content of.
1489
1490 query(language, title, season=None, episode=None, year=None)
1491 Query the provider for subtitles.
1492
1493 Arguments should match as much as possible the actual
1494 parameters for querying the provider
1495
1496 Returns
1497 found subtitles.
1498
1499 Return type
1500 list of Subtitle
1501
1502 Raise ProviderError
1503
1504 list_subtitles(video, languages)
1505 List subtitles for the video with the given languages.
1506
1507 This will call the query() method internally. The parame‐
1508 ters passed to the query() method may vary depending on
1509 the amount of information available in the video.
1510
1511 Parameters
1512
1513 · video (Video) -- video to list subtitles for.
1514
1515 · languages (set of Language) -- languages to
1516 search for.
1517
1518 Returns
1519 found subtitles.
1520
1521 Return type
1522 list of Subtitle
1523
1524 Raise ProviderError
1525
1526 download_subtitle(subtitle)
1527 Download subtitle's content.
1528
1529 Parameters
1530 subtitle (Subtitle) -- subtitle to download.
1531
1532 Raise ProviderError
1533
1534 NapiProjekt
1535 subliminal.providers.napiprojekt.get_subhash(hash)
1536 Get a second hash based on napiprojekt's hash.
1537
1538 Parameters
1539 hash (str) -- napiprojekt's hash.
1540
1541 Returns
1542 the subhash.
1543
1544 Return type
1545 str
1546
1547 class subliminal.providers.napiprojekt.NapiProjektSubtitle(language,
1548 hash)
1549 NapiProjekt Subtitle.
1550
1551 get_matches(video)
1552 Get the matches against the video.
1553
1554 Parameters
1555 video (Video) -- the video to get the matches
1556 with.
1557
1558 Returns
1559 matches of the subtitle.
1560
1561 Return type
1562 set
1563
1564 class subliminal.providers.napiprojekt.NapiProjektProvider
1565 NapiProjekt Provider.
1566
1567 initialize()
1568 Initialize the provider.
1569
1570 Must be called when starting to work with the provider.
1571 This is the place for network initialization or login
1572 operations.
1573
1574 NOTE:
1575 This is called automatically when entering the with
1576 statement
1577
1578 terminate()
1579 Terminate the provider.
1580
1581 Must be called when done with the provider. This is the
1582 place for network shutdown or logout operations.
1583
1584 NOTE:
1585 This is called automatically when exiting the with
1586 statement
1587
1588 query(language, hash)
1589 Query the provider for subtitles.
1590
1591 Arguments should match as much as possible the actual
1592 parameters for querying the provider
1593
1594 Returns
1595 found subtitles.
1596
1597 Return type
1598 list of Subtitle
1599
1600 Raise ProviderError
1601
1602 list_subtitles(video, languages)
1603 List subtitles for the video with the given languages.
1604
1605 This will call the query() method internally. The parame‐
1606 ters passed to the query() method may vary depending on
1607 the amount of information available in the video.
1608
1609 Parameters
1610
1611 · video (Video) -- video to list subtitles for.
1612
1613 · languages (set of Language) -- languages to
1614 search for.
1615
1616 Returns
1617 found subtitles.
1618
1619 Return type
1620 list of Subtitle
1621
1622 Raise ProviderError
1623
1624 download_subtitle(subtitle)
1625 Download subtitle's content.
1626
1627 Parameters
1628 subtitle (Subtitle) -- subtitle to download.
1629
1630 Raise ProviderError
1631
1632 OpenSubtitles
1633 class subliminal.providers.opensubtitles.OpenSubtitlesSubtitle(lan‐
1634 guage, hearing_impaired, page_link, subtitle_id, matched_by,
1635 movie_kind, hash, movie_name, movie_release_name, movie_year,
1636 movie_imdb_id, series_season, series_episode, filename, encoding)
1637 OpenSubtitles Subtitle.
1638
1639 get_matches(video)
1640 Get the matches against the video.
1641
1642 Parameters
1643 video (Video) -- the video to get the matches
1644 with.
1645
1646 Returns
1647 matches of the subtitle.
1648
1649 Return type
1650 set
1651
1652 class subliminal.providers.opensubtitles.OpenSubtitlesProvider(user‐
1653 name=None, password=None)
1654 OpenSubtitles Provider.
1655
1656 Parameters
1657
1658 · username (str) -- username.
1659
1660 · password (str) -- password.
1661
1662 initialize()
1663 Initialize the provider.
1664
1665 Must be called when starting to work with the provider.
1666 This is the place for network initialization or login
1667 operations.
1668
1669 NOTE:
1670 This is called automatically when entering the with
1671 statement
1672
1673 terminate()
1674 Terminate the provider.
1675
1676 Must be called when done with the provider. This is the
1677 place for network shutdown or logout operations.
1678
1679 NOTE:
1680 This is called automatically when exiting the with
1681 statement
1682
1683 query(languages, hash=None, size=None, imdb_id=None, query=None,
1684 season=None, episode=None, tag=None)
1685 Query the provider for subtitles.
1686
1687 Arguments should match as much as possible the actual
1688 parameters for querying the provider
1689
1690 Returns
1691 found subtitles.
1692
1693 Return type
1694 list of Subtitle
1695
1696 Raise ProviderError
1697
1698 list_subtitles(video, languages)
1699 List subtitles for the video with the given languages.
1700
1701 This will call the query() method internally. The parame‐
1702 ters passed to the query() method may vary depending on
1703 the amount of information available in the video.
1704
1705 Parameters
1706
1707 · video (Video) -- video to list subtitles for.
1708
1709 · languages (set of Language) -- languages to
1710 search for.
1711
1712 Returns
1713 found subtitles.
1714
1715 Return type
1716 list of Subtitle
1717
1718 Raise ProviderError
1719
1720 download_subtitle(subtitle)
1721 Download subtitle's content.
1722
1723 Parameters
1724 subtitle (Subtitle) -- subtitle to download.
1725
1726 Raise ProviderError
1727
1728 exception subliminal.providers.opensubtitles.OpenSubtitlesError
1729 Base class for non-generic OpenSubtitlesProvider exceptions.
1730
1731 exception subliminal.providers.opensubtitles.Unauthorized
1732 Exception raised when status is '401 Unauthorized'.
1733
1734 exception subliminal.providers.opensubtitles.NoSession
1735 Exception raised when status is '406 No session'.
1736
1737 exception subliminal.providers.opensubtitles.DownloadLimitReached
1738 Exception raised when status is '407 Download limit reached'.
1739
1740 exception subliminal.providers.opensubtitles.InvalidImdbid
1741 Exception raised when status is '413 Invalid ImdbID'.
1742
1743 exception subliminal.providers.opensubtitles.UnknownUserAgent
1744 Exception raised when status is '414 Unknown User Agent'.
1745
1746 exception subliminal.providers.opensubtitles.DisabledUserAgent
1747 Exception raised when status is '415 Disabled user agent'.
1748
1749 exception subliminal.providers.opensubtitles.ServiceUnavailable
1750 Exception raised when status is '503 Service Unavailable'.
1751
1752 subliminal.providers.opensubtitles.checked(response)
1753 Check a response status before returning it.
1754
1755 Parameters
1756 response -- a response from a XMLRPC call to OpenSubti‐
1757 tles.
1758
1759 Returns
1760 the response.
1761
1762 Raise OpenSubtitlesError
1763
1764 Podnapisi
1765 class subliminal.providers.podnapisi.PodnapisiSubtitle(language, hear‐
1766 ing_impaired, page_link, pid, releases, title, season=None,
1767 episode=None, year=None)
1768 Podnapisi Subtitle.
1769
1770 get_matches(video)
1771 Get the matches against the video.
1772
1773 Parameters
1774 video (Video) -- the video to get the matches
1775 with.
1776
1777 Returns
1778 matches of the subtitle.
1779
1780 Return type
1781 set
1782
1783 class subliminal.providers.podnapisi.PodnapisiProvider
1784 Podnapisi Provider.
1785
1786 initialize()
1787 Initialize the provider.
1788
1789 Must be called when starting to work with the provider.
1790 This is the place for network initialization or login
1791 operations.
1792
1793 NOTE:
1794 This is called automatically when entering the with
1795 statement
1796
1797 terminate()
1798 Terminate the provider.
1799
1800 Must be called when done with the provider. This is the
1801 place for network shutdown or logout operations.
1802
1803 NOTE:
1804 This is called automatically when exiting the with
1805 statement
1806
1807 query(language, keyword, season=None, episode=None, year=None)
1808 Query the provider for subtitles.
1809
1810 Arguments should match as much as possible the actual
1811 parameters for querying the provider
1812
1813 Returns
1814 found subtitles.
1815
1816 Return type
1817 list of Subtitle
1818
1819 Raise ProviderError
1820
1821 list_subtitles(video, languages)
1822 List subtitles for the video with the given languages.
1823
1824 This will call the query() method internally. The parame‐
1825 ters passed to the query() method may vary depending on
1826 the amount of information available in the video.
1827
1828 Parameters
1829
1830 · video (Video) -- video to list subtitles for.
1831
1832 · languages (set of Language) -- languages to
1833 search for.
1834
1835 Returns
1836 found subtitles.
1837
1838 Return type
1839 list of Subtitle
1840
1841 Raise ProviderError
1842
1843 download_subtitle(subtitle)
1844 Download subtitle's content.
1845
1846 Parameters
1847 subtitle (Subtitle) -- subtitle to download.
1848
1849 Raise ProviderError
1850
1851 Shooter
1852 class subliminal.providers.shooter.ShooterSubtitle(language, hash,
1853 download_link)
1854 Shooter Subtitle.
1855
1856 get_matches(video)
1857 Get the matches against the video.
1858
1859 Parameters
1860 video (Video) -- the video to get the matches
1861 with.
1862
1863 Returns
1864 matches of the subtitle.
1865
1866 Return type
1867 set
1868
1869 class subliminal.providers.shooter.ShooterProvider
1870 Shooter Provider.
1871
1872 initialize()
1873 Initialize the provider.
1874
1875 Must be called when starting to work with the provider.
1876 This is the place for network initialization or login
1877 operations.
1878
1879 NOTE:
1880 This is called automatically when entering the with
1881 statement
1882
1883 terminate()
1884 Terminate the provider.
1885
1886 Must be called when done with the provider. This is the
1887 place for network shutdown or logout operations.
1888
1889 NOTE:
1890 This is called automatically when exiting the with
1891 statement
1892
1893 query(language, filename, hash=None)
1894 Query the provider for subtitles.
1895
1896 Arguments should match as much as possible the actual
1897 parameters for querying the provider
1898
1899 Returns
1900 found subtitles.
1901
1902 Return type
1903 list of Subtitle
1904
1905 Raise ProviderError
1906
1907 list_subtitles(video, languages)
1908 List subtitles for the video with the given languages.
1909
1910 This will call the query() method internally. The parame‐
1911 ters passed to the query() method may vary depending on
1912 the amount of information available in the video.
1913
1914 Parameters
1915
1916 · video (Video) -- video to list subtitles for.
1917
1918 · languages (set of Language) -- languages to
1919 search for.
1920
1921 Returns
1922 found subtitles.
1923
1924 Return type
1925 list of Subtitle
1926
1927 Raise ProviderError
1928
1929 download_subtitle(subtitle)
1930 Download subtitle's content.
1931
1932 Parameters
1933 subtitle (Subtitle) -- subtitle to download.
1934
1935 Raise ProviderError
1936
1937 SubsCenter
1938 class subliminal.providers.subscenter.SubsCenterSubtitle(language,
1939 hearing_impaired, page_link, series, season, episode, title, subti‐
1940 tle_id, subtitle_key, downloaded, releases)
1941 SubsCenter Subtitle.
1942
1943 get_matches(video)
1944 Get the matches against the video.
1945
1946 Parameters
1947 video (Video) -- the video to get the matches
1948 with.
1949
1950 Returns
1951 matches of the subtitle.
1952
1953 Return type
1954 set
1955
1956 class subliminal.providers.subscenter.SubsCenterProvider(username=None,
1957 password=None)
1958 SubsCenter Provider.
1959
1960 initialize()
1961 Initialize the provider.
1962
1963 Must be called when starting to work with the provider.
1964 This is the place for network initialization or login
1965 operations.
1966
1967 NOTE:
1968 This is called automatically when entering the with
1969 statement
1970
1971 terminate()
1972 Terminate the provider.
1973
1974 Must be called when done with the provider. This is the
1975 place for network shutdown or logout operations.
1976
1977 NOTE:
1978 This is called automatically when exiting the with
1979 statement
1980
1981 _search_url_titles(**kw)
1982 Search the URL titles by kind for the given title.
1983
1984 Parameters
1985 title (str) -- title to search for.
1986
1987 Returns
1988 the URL titles by kind.
1989
1990 Return type
1991 collections.defaultdict
1992
1993 query(title, season=None, episode=None)
1994 Query the provider for subtitles.
1995
1996 Arguments should match as much as possible the actual
1997 parameters for querying the provider
1998
1999 Returns
2000 found subtitles.
2001
2002 Return type
2003 list of Subtitle
2004
2005 Raise ProviderError
2006
2007 list_subtitles(video, languages)
2008 List subtitles for the video with the given languages.
2009
2010 This will call the query() method internally. The parame‐
2011 ters passed to the query() method may vary depending on
2012 the amount of information available in the video.
2013
2014 Parameters
2015
2016 · video (Video) -- video to list subtitles for.
2017
2018 · languages (set of Language) -- languages to
2019 search for.
2020
2021 Returns
2022 found subtitles.
2023
2024 Return type
2025 list of Subtitle
2026
2027 Raise ProviderError
2028
2029 download_subtitle(subtitle)
2030 Download subtitle's content.
2031
2032 Parameters
2033 subtitle (Subtitle) -- subtitle to download.
2034
2035 Raise ProviderError
2036
2037 TheSubDB
2038 TVsubtitles
2039 class subliminal.providers.tvsubtitles.TVsubtitlesSubtitle(language,
2040 page_link, subtitle_id, series, season, episode, year, rip, release)
2041 TVsubtitles Subtitle.
2042
2043 get_matches(video)
2044 Get the matches against the video.
2045
2046 Parameters
2047 video (Video) -- the video to get the matches
2048 with.
2049
2050 Returns
2051 matches of the subtitle.
2052
2053 Return type
2054 set
2055
2056 class subliminal.providers.tvsubtitles.TVsubtitlesProvider
2057 TVsubtitles Provider.
2058
2059 initialize()
2060 Initialize the provider.
2061
2062 Must be called when starting to work with the provider.
2063 This is the place for network initialization or login
2064 operations.
2065
2066 NOTE:
2067 This is called automatically when entering the with
2068 statement
2069
2070 terminate()
2071 Terminate the provider.
2072
2073 Must be called when done with the provider. This is the
2074 place for network shutdown or logout operations.
2075
2076 NOTE:
2077 This is called automatically when exiting the with
2078 statement
2079
2080 search_show_id(**kw)
2081 Search the show id from the series and year.
2082
2083 Parameters
2084
2085 · series (str) -- series of the episode.
2086
2087 · year (int) -- year of the series, if any.
2088
2089 Returns
2090 the show id, if any.
2091
2092 Return type
2093 int
2094
2095 get_episode_ids(**kw)
2096 Get episode ids from the show id and the season.
2097
2098 Parameters
2099
2100 · show_id (int) -- show id.
2101
2102 · season (int) -- season of the episode.
2103
2104 Returns
2105 episode ids per episode number.
2106
2107 Return type
2108 dict
2109
2110 query(series, season, episode, year=None)
2111 Query the provider for subtitles.
2112
2113 Arguments should match as much as possible the actual
2114 parameters for querying the provider
2115
2116 Returns
2117 found subtitles.
2118
2119 Return type
2120 list of Subtitle
2121
2122 Raise ProviderError
2123
2124 list_subtitles(video, languages)
2125 List subtitles for the video with the given languages.
2126
2127 This will call the query() method internally. The parame‐
2128 ters passed to the query() method may vary depending on
2129 the amount of information available in the video.
2130
2131 Parameters
2132
2133 · video (Video) -- video to list subtitles for.
2134
2135 · languages (set of Language) -- languages to
2136 search for.
2137
2138 Returns
2139 found subtitles.
2140
2141 Return type
2142 list of Subtitle
2143
2144 Raise ProviderError
2145
2146 download_subtitle(subtitle)
2147 Download subtitle's content.
2148
2149 Parameters
2150 subtitle (Subtitle) -- subtitle to download.
2151
2152 Raise ProviderError
2153
2154 Refiners
2155 Refiners enrich a Video object by adding information to it.
2156
2157 A refiner is a simple function:
2158
2159 subliminal.refiners.refine(video, **kwargs)
2160
2161 Parameters
2162
2163 · video (Video) – the video to refine.
2164
2165 · **kwargs – additional parameters for refiners.
2166
2167 Metadata
2168 subliminal.refiners.metadata.refine(video, embedded_subtitles=True,
2169 **kwargs)
2170 Refine a video by searching its metadata.
2171
2172 Several Video attributes can be found:
2173
2174 · resolution
2175
2176 · video_codec
2177
2178 · audio_codec
2179
2180 · subtitle_languages
2181
2182 Parameters
2183 embedded_subtitles (bool) – search for embedded subti‐
2184 tles.
2185
2186 TVDB
2187 subliminal.refiners.tvdb.refine(video, **kwargs)
2188 Refine a video by searching TheTVDB.
2189
2190 NOTE:
2191 This refiner only work for instances of Episode.
2192
2193 Several attributes can be found:
2194
2195 · series
2196
2197 · year
2198
2199 · series_imdb_id
2200
2201 · series_tvdb_id
2202
2203 · title
2204
2205 · imdb_id
2206
2207 · tvdb_id
2208
2209 OMDb
2210 subliminal.refiners.omdb.refine(video, **kwargs)
2211 Refine a video by searching OMDb API.
2212
2213 Several Episode attributes can be found:
2214
2215 · series
2216
2217 · year
2218
2219 · series_imdb_id
2220
2221 Similarly, for a Movie:
2222
2223 · title
2224
2225 · year
2226
2227 · imdb_id
2228
2229 Extensions
2230 class subliminal.extensions.RegistrableExtensionManager(namespace,
2231 internal_extensions, **kwargs)
2232 :class:~stevedore.extensions.ExtensionManager` with support for
2233 registration.
2234
2235 It allows loading of internal extensions without setup and reg‐
2236 istering/unregistering additional extensions.
2237
2238 Loading is done in this order:
2239
2240 · Entry point extensions
2241
2242 · Internal extensions
2243
2244 · Registered extensions
2245
2246 Parameters
2247
2248 · namespace (str) – namespace argument for :class:~steve‐
2249 dore.extensions.ExtensionManager`.
2250
2251 · internal_extensions (list) – internal extensions to use
2252 with entry point syntax.
2253
2254 · **kwargs – additional parameters for the :class:~steve‐
2255 dore.extensions.ExtensionManager` constructor.
2256
2257 registered_extensions = None
2258 Registered extensions with entry point syntax
2259
2260 internal_extensions = None
2261 Internal extensions with entry point syntax
2262
2263 register(entry_point)
2264 Register an extension
2265
2266 Parameters
2267 entry_point (str) – extension to register (entry
2268 point syntax).
2269
2270 Raise ValueError if already registered.
2271
2272 unregister(entry_point)
2273 Unregister a provider
2274
2275 Parameters
2276 entry_point (str) – provider to unregister (entry
2277 point syntax).
2278
2279 subliminal.extensions.provider_manager = <subliminal.extensions.Regis‐
2280 trableExtensionManager object>
2281 Provider manager
2282
2283 subliminal.extensions.refiner_manager = <subliminal.extensions.Regis‐
2284 trableExtensionManager object>
2285 Refiner manager
2286
2287 Score
2288 This module provides the default implementation of the compute_score
2289 parameter in download_best_subtitles() and download_best_subtitles().
2290
2291 NOTE:
2292 To avoid unnecessary dependency on sympy and boost subliminal’s
2293 import time, the resulting scores are hardcoded here and manually
2294 updated when the set of equations change.
2295
2296 Available matches:
2297
2298 · hash
2299
2300 · title
2301
2302 · year
2303
2304 · series
2305
2306 · season
2307
2308 · episode
2309
2310 · release_group
2311
2312 · format
2313
2314 · audio_codec
2315
2316 · resolution
2317
2318 · hearing_impaired
2319
2320 · video_codec
2321
2322 · series_imdb_id
2323
2324 · imdb_id
2325
2326 · tvdb_id
2327
2328 subliminal.score.episode_scores = {'audio_codec': 3, 'episode': 30,
2329 'format': 7, 'hash': 359, 'hearing_impaired': 1, 'release_group': 15,
2330 'resolution': 2, 'season': 30, 'series': 180, 'video_codec': 2, 'year':
2331 90}
2332 Scores for episodes
2333
2334 subliminal.score.movie_scores = {'audio_codec': 3, 'format': 7, 'hash':
2335 119, 'hearing_impaired': 1, 'release_group': 15, 'resolution': 2,
2336 'title': 60, 'video_codec': 2, 'year': 30}
2337 Scores for movies
2338
2339 subliminal.score.equivalent_release_groups = (set(['DIMENSION',
2340 'LOL']), set(['FLEET', 'IMMERSE', 'ASAP']))
2341 Equivalent release groups
2342
2343 subliminal.score.get_equivalent_release_groups(release_group)
2344 Get all the equivalents of the given release group.
2345
2346 Parameters
2347 release_group (str) – the release group to get the equiv‐
2348 alents of.
2349
2350 Returns
2351 the equivalent release groups.
2352
2353 Return type
2354 set
2355
2356 subliminal.score.get_scores(video)
2357 Get the scores dict for the given video.
2358
2359 This will return either episode_scores or movie_scores based on
2360 the type of the video.
2361
2362 Parameters
2363 video (Video) – the video to compute the score against.
2364
2365 Returns
2366 the scores dict.
2367
2368 Return type
2369 dict
2370
2371 subliminal.score.compute_score(subtitle, video, hearing_impaired=None)
2372 Compute the score of the subtitle against the video with hear‐
2373 ing_impaired preference.
2374
2375 compute_score() uses the Subtitle.get_matches method and applies
2376 the scores (either from episode_scores or movie_scores) after
2377 some processing.
2378
2379 Parameters
2380
2381 · subtitle (Subtitle) – the subtitle to compute the score
2382 of.
2383
2384 · video (Video) – the video to compute the score against.
2385
2386 · hearing_impaired (bool) – hearing impaired preference.
2387
2388 Returns
2389 score of the subtitle.
2390
2391 Return type
2392 int
2393
2394 Utils
2395 subliminal.utils.hash_opensubtitles(video_path)
2396 Compute a hash using OpenSubtitles’ algorithm.
2397
2398 Parameters
2399 video_path (str) – path of the video.
2400
2401 Returns
2402 the hash.
2403
2404 Return type
2405 str
2406
2407 subliminal.utils.hash_thesubdb(video_path)
2408 Compute a hash using TheSubDB’s algorithm.
2409
2410 Parameters
2411 video_path (str) – path of the video.
2412
2413 Returns
2414 the hash.
2415
2416 Return type
2417 str
2418
2419 subliminal.utils.hash_napiprojekt(video_path)
2420 Compute a hash using NapiProjekt’s algorithm.
2421
2422 Parameters
2423 video_path (str) – path of the video.
2424
2425 Returns
2426 the hash.
2427
2428 Return type
2429 str
2430
2431 subliminal.utils.hash_shooter(video_path)
2432 Compute a hash using Shooter’s algorithm
2433
2434 Parameters
2435 video_path (string) – path of the video
2436
2437 Returns
2438 the hash
2439
2440 Return type
2441 string
2442
2443 subliminal.utils.sanitize(string, ignore_characters=None)
2444 Sanitize a string to strip special characters.
2445
2446 Parameters
2447
2448 · string (str) – the string to sanitize.
2449
2450 · ignore_characters (set) – characters to ignore.
2451
2452 Returns
2453 the sanitized string.
2454
2455 Return type
2456 str
2457
2458 subliminal.utils.sanitize_release_group(string)
2459 Sanitize a release_group string to remove content in square
2460 brackets.
2461
2462 Parameters
2463 string (str) – the release group to sanitize.
2464
2465 Returns
2466 the sanitized release group.
2467
2468 Return type
2469 str
2470
2471 subliminal.utils.timestamp(date)
2472 Get the timestamp of the date, python2/3 compatible
2473
2474 Parameters
2475 date (datetime.datetime) – the utc date.
2476
2477 Returns
2478 the timestamp of the date.
2479
2480 Return type
2481 float
2482
2483 Cache
2484 subliminal.cache.SHOW_EXPIRATION_TIME
2485 Expiration time for show caching
2486
2487 subliminal.cache.EPISODE_EXPIRATION_TIME
2488 Expiration time for episode caching
2489
2490 subliminal.cache.REFINER_EXPIRATION_TIME
2491 Expiration time for scraper searches
2492
2493 subliminal.cache.region
2494 The CacheRegion
2495
2496 Refer to dogpile.cache’s region configuration documentation to see how
2497 to configure the region
2498
2499 CLI
2500 Exceptions
2501 exception subliminal.exceptions.Error
2502 Base class for exceptions in subliminal.
2503
2504 exception subliminal.exceptions.ProviderError
2505 Exception raised by providers.
2506
2507 exception subliminal.exceptions.ConfigurationError
2508 Exception raised by providers when badly configured.
2509
2510 exception subliminal.exceptions.AuthenticationError
2511 Exception raised by providers when authentication failed.
2512
2513 exception subliminal.exceptions.TooManyRequests
2514 Exception raised by providers when too many requests are made.
2515
2516 exception subliminal.exceptions.DownloadLimitExceeded
2517 Exception raised by providers when download limit is exceeded.
2518
2520 MIT
2521
2522 · genindex
2523
2524 · modindex
2525
2526 · search
2527
2529 Antoine Bertin
2530
2532 2016, Antoine Bertin
2533
2534
2535
2536
25372.0.5 Dec 28, 2018 SUBLIMINAL(1)