[Python-modules-commits] r29571 - in packages/subliminal/trunk/debian/patches (4 files)

emillon-guest at users.alioth.debian.org emillon-guest at users.alioth.debian.org
Tue Jul 1 12:03:52 UTC 2014


    Date: Tuesday, July 1, 2014 @ 12:03:51
  Author: emillon-guest
Revision: 29571

subliminal: fix python3 CLI tool

Added:
  packages/subliminal/trunk/debian/patches/babelfish.patch
  packages/subliminal/trunk/debian/patches/guessit.patch
  packages/subliminal/trunk/debian/patches/python3.patch
Modified:
  packages/subliminal/trunk/debian/patches/series

Added: packages/subliminal/trunk/debian/patches/babelfish.patch
===================================================================
--- packages/subliminal/trunk/debian/patches/babelfish.patch	                        (rev 0)
+++ packages/subliminal/trunk/debian/patches/babelfish.patch	2014-07-01 12:03:51 UTC (rev 29571)
@@ -0,0 +1,120 @@
+Origin: upstream, commit:f0519bbe commit:5e26185c
+Description: fixes for babelfish 0.5.1 
+
+--- a/requirements.txt
++++ b/requirements.txt
+@@ -4,6 +4,6 @@
+ enzyme>=0.4.0
+ html5lib>=0.99
+ dogpile.cache>=0.5.2
+-babelfish>=0.4.0
++babelfish>=0.5.1
+ chardet>=1.0.3
+ pysrt>=0.5.0
+--- a/setup.py
++++ b/setup.py
+@@ -31,10 +31,7 @@
+                                  'opensubtitles = subliminal.providers.opensubtitles:OpenSubtitlesProvider',
+                                  'podnapisi = subliminal.providers.podnapisi:PodnapisiProvider',
+                                  'thesubdb = subliminal.providers.thesubdb:TheSubDBProvider',
+-                                 'tvsubtitles = subliminal.providers.tvsubtitles:TVsubtitlesProvider'],
+-        'babelfish.language_converters': ['addic7ed = subliminal.converters.addic7ed:Addic7edConverter',
+-                                          'podnapisi = subliminal.converters.podnapisi:PodnapisiConverter',
+-                                          'tvsubtitles = subliminal.converters.tvsubtitles:TVsubtitlesConverter']
++                                 'tvsubtitles = subliminal.providers.tvsubtitles:TVsubtitlesProvider']
+     },
+     install_requires=open('requirements.txt').readlines(),
+     test_suite='subliminal.tests.suite')
+--- a/subliminal/converters/addic7ed.py
++++ b/subliminal/converters/addic7ed.py
+@@ -1,11 +1,11 @@
+ # -*- coding: utf-8 -*-
+ from __future__ import unicode_literals
+-from babelfish import LanguageReverseConverter, get_language_converter
++from babelfish import LanguageReverseConverter, language_converters
+ 
+ 
+ class Addic7edConverter(LanguageReverseConverter):
+     def __init__(self):
+-        self.name_converter = get_language_converter('name')
++        self.name_converter = language_converters['name']
+         self.from_addic7ed = {'Català': ('cat',), 'Chinese (Simplified)': ('zho',), 'Chinese (Traditional)': ('zho',),
+                               'Euskera': ('eus',), 'Galego': ('glg',), 'Greek': ('ell',), 'Malay': ('msa',),
+                               'Portuguese (Brazilian)': ('por', 'BR'), 'Serbian (Cyrillic)': ('srp', None, 'Cyrl'),
+--- a/subliminal/converters/tvsubtitles.py
++++ b/subliminal/converters/tvsubtitles.py
+@@ -1,11 +1,11 @@
+ # -*- coding: utf-8 -*-
+ from __future__ import unicode_literals
+-from babelfish import LanguageReverseConverter, get_language_converter
++from babelfish import LanguageReverseConverter, language_converters
+ 
+ 
+ class TVsubtitlesConverter(LanguageReverseConverter):
+     def __init__(self):
+-        self.alpha2_converter = get_language_converter('alpha2')
++        self.alpha2_converter = language_converters['alpha2']
+         self.from_tvsubtitles = {'br': ('por', 'BR'), 'ua': ('ukr',), 'gr': ('ell',), 'cn': ('zho',), 'jp': ('jpn',),
+                                  'cz': ('ces',)}
+         self.to_tvsubtitles = {v: k for k, v in self.from_tvsubtitles}
+--- a/subliminal/providers/addic7ed.py
++++ b/subliminal/providers/addic7ed.py
+@@ -14,6 +14,7 @@
+ 
+ 
+ logger = logging.getLogger(__name__)
++babelfish.language_converters.register('addic7ed = subliminal.converters.addic7ed:Addic7edConverter')
+ 
+ 
+ class Addic7edSubtitle(Subtitle):
+--- a/subliminal/providers/podnapisi.py
++++ b/subliminal/providers/podnapisi.py
+@@ -18,6 +18,7 @@
+ 
+ 
+ logger = logging.getLogger(__name__)
++babelfish.language_converters.register('podnapisi = subliminal.converters.podnapisi:PodnapisiConverter')
+ 
+ 
+ class PodnapisiSubtitle(Subtitle):
+@@ -67,7 +68,7 @@
+ 
+ 
+ class PodnapisiProvider(Provider):
+-    languages = {babelfish.Language.frompodnapisi(l) for l in babelfish.get_language_converter('podnapisi').codes}
++    languages = {babelfish.Language.frompodnapisi(l) for l in babelfish.language_converters['podnapisi'].codes}
+     video_types = (Episode, Movie)
+     server = 'http://simple.podnapisi.net'
+     link_re = re.compile('^.*(?P<link>/ppodnapisi/download/i/\d+/k/.*$)')
+--- a/subliminal/providers/tvsubtitles.py
++++ b/subliminal/providers/tvsubtitles.py
+@@ -17,6 +17,7 @@
+ 
+ 
+ logger = logging.getLogger(__name__)
++babelfish.language_converters.register('tvsubtitles = subliminal.converters.tvsubtitles:TVsubtitlesConverter')
+ 
+ 
+ class TVsubtitlesSubtitle(Subtitle):
+--- a/subliminal/video.py
++++ b/subliminal/video.py
+@@ -156,7 +156,7 @@
+     :rtype: set
+ 
+     """
+-    language_extensions = tuple('.' + c for c in babelfish.get_language_converter('alpha2').codes)
++    language_extensions = tuple('.' + c for c in babelfish.language_converters['alpha2'].codes)
+     dirpath, filename = os.path.split(path)
+     subtitles = set()
+     for p in os.listdir(dirpath):
+--- a/subliminal/providers/opensubtitles.py
++++ b/subliminal/providers/opensubtitles.py
+@@ -83,7 +83,7 @@
+ 
+ 
+ class OpenSubtitlesProvider(Provider):
+-    languages = {babelfish.Language.fromopensubtitles(l) for l in babelfish.get_language_converter('opensubtitles').codes}
++    languages = {babelfish.Language.fromopensubtitles(l) for l in babelfish.language_converters['opensubtitles'].codes}
+ 
+     def __init__(self):
+         self.server = ServerProxy('http://api.opensubtitles.org/xml-rpc', transport=TimeoutTransport(10))

Added: packages/subliminal/trunk/debian/patches/guessit.patch
===================================================================
--- packages/subliminal/trunk/debian/patches/guessit.patch	                        (rev 0)
+++ packages/subliminal/trunk/debian/patches/guessit.patch	2014-07-01 12:03:51 UTC (rev 29571)
@@ -0,0 +1,34 @@
+Origin: upstream, commit:c142233f, commit:5ffa344f
+Description: fixes for guessit 0.7
+
+--- a/requirements.txt
++++ b/requirements.txt
+@@ -1,5 +1,5 @@
+ beautifulsoup4>=4.3.2
+-guessit>=0.6.2
++guessit>=0.7
+ requests>=2.0.1
+ enzyme>=0.4.0
+ html5lib>=0.99
+--- a/subliminal/video.py
++++ b/subliminal/video.py
+@@ -182,7 +182,7 @@
+     """
+     dirpath, filename = os.path.split(path)
+     logger.info('Scanning video %r in %r', filename, dirpath)
+-    video = Video.fromguess(path, guessit.guess_file_info(path, 'autodetect'))
++    video = Video.fromguess(path, guessit.guess_file_info(path))
+     video.size = os.path.getsize(path)
+     if video.size > 10485760:
+         logger.debug('Size is %d', video.size)
+--- a/subliminal/cli.py
++++ b/subliminal/cli.py
+@@ -147,7 +147,7 @@
+                          embedded_subtitles=not args.force, age=args.age)
+ 
+     # guess videos
+-    videos.extend([Video.fromguess(os.path.split(p)[1], guessit.guess_file_info(p, 'autodetect')) for p in args.paths
++    videos.extend([Video.fromguess(os.path.split(p)[1], guessit.guess_file_info(p)) for p in args.paths
+                    if not os.path.exists(p)])
+ 
+     # download best subtitles

Added: packages/subliminal/trunk/debian/patches/python3.patch
===================================================================
--- packages/subliminal/trunk/debian/patches/python3.patch	                        (rev 0)
+++ packages/subliminal/trunk/debian/patches/python3.patch	2014-07-01 12:03:51 UTC (rev 29571)
@@ -0,0 +1,118 @@
+Origin: upstream, commit:84d890d7 (compat.py), commit:560dea3e, commit:7acfb3f0
+Description: Python3 improvements
+
+This is needed to bring a python3 CLI tool.
+
+--- a/subliminal/providers/opensubtitles.py
++++ b/subliminal/providers/opensubtitles.py
+@@ -4,13 +4,13 @@
+ import logging
+ import os
+ import re
+-import xmlrpclib
+ import zlib
+ import babelfish
+ import chardet as charade
+ import guessit
+ from . import Provider
+ from .. import __version__
++from ..compat import ServerProxy, TimeoutTransport
+ from ..exceptions import ProviderError, ProviderNotAvailable, InvalidSubtitle
+ from ..subtitle import Subtitle, is_valid_subtitle, compute_guess_matches
+ from ..video import Episode, Movie
+@@ -86,7 +86,7 @@
+     languages = {babelfish.Language.fromopensubtitles(l) for l in babelfish.get_language_converter('opensubtitles').codes}
+ 
+     def __init__(self):
+-        self.server = xmlrpclib.ServerProxy('http://api.opensubtitles.org/xml-rpc')
++        self.server = ServerProxy('http://api.opensubtitles.org/xml-rpc', transport=TimeoutTransport(10))
+         self.token = None
+ 
+     def initialize(self):
+--- a/subliminal/providers/thesubdb.py
++++ b/subliminal/providers/thesubdb.py
+@@ -65,7 +65,7 @@
+         elif r.status_code != 200:
+             raise ProviderError('Request failed with status code %d' % r.status_code)
+         return [TheSubDBSubtitle(language, hash) for language in
+-                {babelfish.Language.fromalpha2(l) for l in r.content.split(',')}]
++                {babelfish.Language.fromalpha2(l) for l in r.content.decode('utf-8').split(',')}]
+ 
+     def list_subtitles(self, video, languages):
+         return [s for s in self.query(video.hashes['thesubdb']) if s.language in languages]
+--- a/subliminal/cli.py
++++ b/subliminal/cli.py
+@@ -43,7 +43,7 @@
+     providers = [ep.name for ep in pkg_resources.iter_entry_points(PROVIDERS_ENTRY_POINT)]
+     filtering_group.add_argument('-p', '--providers', nargs='+', metavar='PROVIDER',
+                                  help='providers to use (%s)' % ', '.join(providers))
+-    filtering_group.add_argument('-m', '--min-score', type=int,
++    filtering_group.add_argument('-m', '--min-score', type=int, default=0,
+                                  help='minimum score for subtitles (0-%d for episodes, 0-%d for movies)'
+                                  % (Episode.scores['hash'], Movie.scores['hash']))
+     filtering_group.add_argument('-a', '--age', help='download subtitles for videos newer than AGE e.g. 12h, 1w2d')
+@@ -75,7 +75,8 @@
+ 
+     # parse paths
+     try:
+-        args.paths = [os.path.abspath(os.path.expanduser(p.decode('utf-8'))) for p in args.paths]
++        args.paths = [os.path.abspath(os.path.expanduser(p.decode('utf-8') if isinstance(p, bytes) else p))
++                      for p in args.paths]
+     except UnicodeDecodeError:
+         parser.error('argument paths: encodings is not utf-8: %r' % args.paths)
+ 
+--- a/subliminal/video.py
++++ b/subliminal/video.py
+@@ -1,5 +1,5 @@
+ # -*- coding: utf-8 -*-
+-from __future__ import unicode_literals
++from __future__ import unicode_literals, division
+ import datetime
+ import hashlib
+ import logging
+@@ -348,13 +348,13 @@
+         filehash = filesize
+         if filesize < 65536 * 2:
+             return None
+-        for _ in range(65536 / bytesize):
++        for _ in range(65536 // bytesize):
+             filebuffer = f.read(bytesize)
+             (l_value,) = struct.unpack(b'q', filebuffer)
+             filehash += l_value
+             filehash = filehash & 0xFFFFFFFFFFFFFFFF  # to remain as 64bit number
+         f.seek(max(0, filesize - 65536), 0)
+-        for _ in range(65536 / bytesize):
++        for _ in range(65536 // bytesize):
+             filebuffer = f.read(bytesize)
+             (l_value,) = struct.unpack(b'q', filebuffer)
+             filehash += l_value
+@@ -378,4 +378,4 @@
+         data = f.read(readsize)
+         f.seek(-readsize, os.SEEK_END)
+         data += f.read(readsize)
+-    return hashlib.md5(data).hexdigest().decode('ascii')
++    return hashlib.md5(data).hexdigest()
+--- /dev/null
++++ b/subliminal/compat.py
+@@ -0,0 +1,21 @@
++# -*- coding: utf-8 -*-
++import sys
++import socket
++
++
++if sys.version_info[0] == 2:
++    from xmlrpclib import ServerProxy, Transport
++    from httplib import HTTPConnection
++elif sys.version_info[0] == 3:
++    from xmlrpc.client import ServerProxy, Transport
++    from http.client import HTTPConnection
++
++
++class TimeoutTransport(Transport, object):
++    def __init__(self, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, *args, **kwargs):
++        super(TimeoutTransport, self).__init__(*args, **kwargs)
++        self.timeout = timeout
++
++    def make_connection(self, host):
++        h = HTTPConnection(host, timeout=self.timeout)
++        return h

Modified: packages/subliminal/trunk/debian/patches/series
===================================================================
--- packages/subliminal/trunk/debian/patches/series	2014-07-01 00:51:04 UTC (rev 29570)
+++ packages/subliminal/trunk/debian/patches/series	2014-07-01 12:03:51 UTC (rev 29571)
@@ -1,2 +1,5 @@
 charade.patch
 bounds.patch
+python3.patch
+babelfish.patch
+guessit.patch




More information about the Python-modules-commits mailing list