Closed hadim closed 10 years ago
I think because that is planned for mileston 0.8 see milestones subliminal
If you want to help you can make pysrt python3 compatible: https://github.com/byroot/pysrt/issues/31
Could you make a setup.py which going to install pysrt in case of python 2.7 or pysrt3 in case of python 3 detected ?
And what about requirements.txt? That's a lot of hacks to get python3 to work in subliminal this way and from what I saw that's just pysrt that's blocking. I'd rather make pysrt compatible with python3.
That's a small hack I think you could add it waiting pysrt to be compatible with py3. Py3 compatibility seems hard to implement for what I heard: https://github.com/byroot/pysrt/issues/31.
Ì was thinking about something like that:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import sys
required_packages = open('requirements.txt').readlines()
if sys.version_info >= (3,0):
required_packages.remove('pysrt>=0.5.0')
required_packages.append('pysrt3>=0.5.0')
setup(name='subliminal',
version='0.7.1',
license='MIT',
description='Subtitles, faster than your thoughts',
long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(),
keywords='subtitle subtitles video movie episode tv show',
url='https://github.com/Diaoul/subliminal',
author='Antoine Bertin',
author_email='diaoulael@gmail.com',
packages=find_packages(),
classifiers=['Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: Multimedia :: Video'],
entry_points={
'console_scripts': ['subliminal = subliminal.cli:subliminal'],
'subliminal.providers': ['addic7ed = subliminal.providers.addic7ed:Addic7edProvider',
'bierdopje = subliminal.providers.bierdopje:BierDopjeProvider',
'opensubtitles = subliminal.providers.opensubtitles:OpenSubtitlesProvider',
'thesubdb = subliminal.providers.thesubdb:TheSubDBProvider',
'tvsubtitles = subliminal.providers.tvsubtitles:TVsubtitlesProvider'],
'babelfish.converters': ['addic7ed = subliminal.converters.addic7ed:Addic7edConverter',
'tvsubtitles = subliminal.converters.tvsubtitles:TVsubtitlesConverter']
},
install_requires=required_packages,
test_suite='subliminal.tests.suite')
Not to heavy in my mind. What do you think ?
I'll give a try to make pysrt python3 compatible before doing something like that. Having 1 dependency that forces me to do some hacks like that is not cool.
Ok I perfectly understand it.
So I close it
Or maybe we should let it open and target it to milestones 0.8. So we can still discuss on python 3 support.
I let you decide
There's pysrt3 which is allegedly Python3 compatible?
Installed it, hacked required.txt to require it, now it chokes on some other issues. Just fyi.
doron@Slack:~$ subliminal -l he -- blah
Traceback (most recent call last):
File "/usr/bin/subliminal", line 9, in
What do you think about https://github.com/byroot/pysrt/pull/38 ? Can you review it?
pysrt-1.0.0 was released today, it is python3 compatible: https://pypi.python.org/pypi/pysrt https://github.com/byroot/pysrt/blob/master/.travis.yml
Great, I'll have a look to python 3 compatibility soon then. I'd like to wait for guessit 0.7 before releasing subliminal 0.8 though.
After 560dea3e3e8f259e4ad2eb963cf4a40770aa283d the only issue remaining according to unittests is https://github.com/wackou/guessit/issues/74.
I tried subliminal with last master branch (for guessit too) and I got this error :
(sub3)hadim boromir ~ $ subliminal --debug Incoming/The\ Hobbit\ The\ Desolation\ Of\ Smaug\ \ \[2013\]\ DVDScr\ 720p\ x264.AAC-ZoNe/ -l fr
Traceback (most recent call last):
File "/home/hadim/local/virtualenvs/sub3/bin/subliminal", line 9, in <module>
load_entry_point('subliminal==0.8.0-dev', 'console_scripts', 'subliminal')()
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/cli.py", line 80, in subliminal
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/cli.py", line 80, in <listcomp>
AttributeError: 'str' object has no attribute 'decode'
(sub3)hadim boromir ~ $
I made small modifications (I post a diff in the next comment). But now I got an error which seems related to babelfish :
(sub3)hadim boromir ~ $ subliminal --debug Incoming/The\ Hobbit\ The\ Desolation\ Of\ Smaug\ \ \[2013\]\ DVDScr\ 720p\ x264.AAC-ZoNe/ -l fr
INFO [subliminal.video-scan_videos:313] Scanning directory '/home/hadim/Incoming/The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe'
INFO [subliminal.video-scan_video:200] Scanning video 'The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe.mp4' in '/home/hadim/Incoming/The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe'
DEBUG [GuessFiletype-guess_filetype:185] Nothing characteristic found, assuming type = movie
DEBUG [GuessFiletype-process:197] Found with confidence 1.00: {'type': 'movie'}
DEBUG [GuessFiletype-process:209] Found with confidence 1.00: {'container': 'mp4', 'mimetype': 'video/mp4'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'other': 'Screener'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'format': 'DVD'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'screenSize': '720p'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'videoCodec': 'h264'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'audioCodec': 'AAC'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'other': 'Screener'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'format': 'DVD'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'screenSize': '720p'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'videoCodec': 'h264'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'audioCodec': 'AAC'}
DEBUG [GuessYear-find_and_split_node:115] Found with confidence 1.00: {'year': 2013}
DEBUG [GuessYear-find_and_split_node:115] Found with confidence 1.00: {'year': 2013}
DEBUG [GuessReleaseGroup-find_and_split_node:115] Found with confidence 1.00: {'releaseGroup': 'ZoNe'}
DEBUG [GuessReleaseGroup-find_and_split_node:115] Found with confidence 1.00: {'releaseGroup': 'ZoNe'}
DEBUG [GuessMovieTitleFromPosition-process:62] folder: [<MatchTree: root=The Hobbit The Desolation Of Smaug >]
DEBUG [GuessMovieTitleFromPosition-process:63] basename: [<MatchTree: root=The Hobbit The Desolation Of Smaug >]
DEBUG [GuessMovieTitleFromPosition-found_property:46] Found with confidence 0.80: {'title': 'The Hobbit The Desolation Of Smaug'}
DEBUG [guessit.matcher-__init__:122] Found match tree:
01111 22222 33333333 44444444444444444444444444444444444444444444444444444444444444444444 55555555555555555555555555555555555555555555555555555555555555555555 666
00000 00000 00000000 00000000000000000000000000000000000011111122222222222222222222222222 00000000000000000000000000000000000011111122222222222222222222222222 000
01111200001112222222222222222222 01111200001112222222222222222222
0111 0111122222222222222 0111 0111122222222222222
01111222222222 01111222222222
011122222 011122222
01111 01111
/home/hadim/Incoming/____________________________________[____] ______ ____ ____.___-____/The Hobbit The Desolation Of Smaug [____] ______ ____ ____.___-____.___
tttttttttttttttttttttttttttttttttttt yyyy fffxxx ssss vvvv aaa rrrr yyyy fffxxx ssss vvvv aaa rrrr ccc
/home/hadim/Incoming/The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe/The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe.mp4
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'year' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'format' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'releaseGroup' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'audioCodec' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'videoCodec' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'screenSize' with confidence 1.00
DEBUG [guessit.matchtree-matched:378] Final result: {
[1.00] "year": 2013,
[1.00] "format": "DVD",
[1.00] "container": "mp4",
[1.00] "other": [
"Screener"
],
[1.00] "releaseGroup": "ZoNe",
[1.00] "audioCodec": "AAC",
[0.80] "title": "The Hobbit The Desolation Of Smaug",
[1.00] "screenSize": "720p",
[1.00] "mimetype": "video/mp4",
[1.00] "videoCodec": "h264",
[1.00] "type": "movie"
}
INFO [guessit-_guess_filename:111] Running 2nd pass
DEBUG [GuessFiletype-guess_filetype:185] Nothing characteristic found, assuming type = movie
DEBUG [GuessFiletype-process:197] Found with confidence 1.00: {'type': 'movie'}
DEBUG [GuessFiletype-process:209] Found with confidence 1.00: {'container': 'mp4', 'mimetype': 'video/mp4'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'other': 'Screener'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'format': 'DVD'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'screenSize': '720p'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'videoCodec': 'h264'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'audioCodec': 'AAC'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'other': 'Screener'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'format': 'DVD'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'screenSize': '720p'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'videoCodec': 'h264'}
DEBUG [GuessProperties-find_and_split_node:115] Found with confidence 1.00: {'audioCodec': 'AAC'}
DEBUG [GuessYear-find_and_split_node:115] Found with confidence 1.00: {'year': 2013}
DEBUG [GuessYear-find_and_split_node:115] Found with confidence 1.00: {'year': 2013}
DEBUG [GuessReleaseGroup-find_and_split_node:115] Found with confidence 1.00: {'releaseGroup': 'ZoNe'}
DEBUG [GuessReleaseGroup-find_and_split_node:115] Found with confidence 1.00: {'releaseGroup': 'ZoNe'}
DEBUG [GuessMovieTitleFromPosition-process:62] folder: [<MatchTree: root=The Hobbit The Desolation Of Smaug >]
DEBUG [GuessMovieTitleFromPosition-process:63] basename: [<MatchTree: root=The Hobbit The Desolation Of Smaug >]
DEBUG [GuessMovieTitleFromPosition-found_property:46] Found with confidence 0.80: {'title': 'The Hobbit The Desolation Of Smaug'}
DEBUG [guessit.matcher-__init__:122] Found match tree:
01111 22222 33333333 44444444444444444444444444444444444444444444444444444444444444444444 55555555555555555555555555555555555555555555555555555555555555555555 666
00000 00000 00000000 00000000000000000000000000000000000011111122222222222222222222222222 00000000000000000000000000000000000011111122222222222222222222222222 000
01111200001112222222222222222222 01111200001112222222222222222222
0111 0111122222222222222 0111 0111122222222222222
01111222222222 01111222222222
011122222 011122222
01111 01111
/home/hadim/Incoming/____________________________________[____] ______ ____ ____.___-____/The Hobbit The Desolation Of Smaug [____] ______ ____ ____.___-____.___
tttttttttttttttttttttttttttttttttttt yyyy fffxxx ssss vvvv aaa rrrr yyyy fffxxx ssss vvvv aaa rrrr ccc
/home/hadim/Incoming/The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe/The Hobbit The Desolation Of Smaug [2013] DVDScr 720p x264.AAC-ZoNe.mp4
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'year' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'format' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'releaseGroup' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'audioCodec' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'videoCodec' with confidence 1.00
DEBUG [guessit.guess-_merge_similar_guesses_nocheck:368] Updating matching property 'screenSize' with confidence 1.00
DEBUG [guessit.matchtree-matched:378] Final result: {
[1.00] "year": 2013,
[1.00] "format": "DVD",
[1.00] "container": "mp4",
[1.00] "other": [
"Screener"
],
[1.00] "releaseGroup": "ZoNe",
[1.00] "audioCodec": "AAC",
[0.80] "title": "The Hobbit The Desolation Of Smaug",
[1.00] "screenSize": "720p",
[1.00] "mimetype": "video/mp4",
[1.00] "videoCodec": "h264",
[1.00] "type": "movie"
}
DEBUG [subliminal.video-scan_video:204] Size is 1771586326
DEBUG [subliminal.video-scan_video:207] Computed hashes {'thesubdb': '1c2301ad4edad2c4f4d2a95808e289c5', 'opensubtitles': '121c5fd5de23952b'}
Traceback (most recent call last):
File "/home/hadim/local/virtualenvs/sub3/bin/subliminal", line 9, in <module>
load_entry_point('subliminal==0.8.0-dev', 'console_scripts', 'subliminal')()
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/cli.py", line 172, in subliminal
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/video.py", line 357, in scan_videos
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/video.py", line 211, in scan_video
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/video.py", line 175, in scan_subtitle_languages
AttributeError: 'module' object has no attribute 'get_language_converter'
Here there is the diff I made to subliminal code :
(sub3)hadim boromir subliminal (master *) $ git diff
diff --git a/subliminal/cli.py b/subliminal/cli.py
index 81ea305..0fc0d15 100644
--- a/subliminal/cli.py
+++ b/subliminal/cli.py
@@ -77,7 +77,7 @@ def subliminal():
# parse paths
try:
- args.paths = [os.path.abspath(os.path.expanduser(p.decode('utf-8'))) for p in args.pat
+ args.paths = [os.path.abspath(os.path.expanduser(p)) for p in args.paths]
except UnicodeDecodeError:
parser.error('argument paths: encodings is not utf-8: %r' % args.paths)
diff --git a/subliminal/video.py b/subliminal/video.py
index cbe06c4..dfc4b92 100644
--- a/subliminal/video.py
+++ b/subliminal/video.py
@@ -376,13 +376,13 @@ def hash_opensubtitles(video_path):
filehash = filesize
if filesize < 65536 * 2:
return None
- for _ in range(65536 / bytesize):
+ for _ in range(int(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(int(65536 / bytesize)):
filebuffer = f.read(bytesize)
(l_value,) = struct.unpack(b'q', filebuffer)
filehash += l_value
@@ -406,4 +406,4 @@ def hash_thesubdb(video_path):
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()
And the module I used :
(sub3)hadim boromir subliminal (master *) $ pip freeze
babelfish==0.5.0
beautifulsoup4==4.3.2
charade==1.0.3
dogpile.cache==0.5.3
dogpile.core==0.4.1
enzyme==0.4.1
-e git+https://github.com/wackou/guessit.git@236e2537a0821bcdb37cbf1bae40bd61fd567a90#egg=guessit-master
html5lib==1.0b3
pysrt==1.0.0
pyxdg==0.25
requests==2.2.1
six==1.5.2
stevedore==0.13
subliminal==0.8.0-dev
I still have the same issue with last babelfish version :
-e git+https://github.com/Diaoul/babelfish.git@c214d621f2c0cbe5c2b13868ff984d4a20883f1b#egg=babelfish-0.5.0
By looking at babelfish code get_language_converter
seems to have been deleted by language_converters
but I still have an issue if I change that :
.
.
.
Traceback (most recent call last):
File "/home/hadim/local/virtualenvs/sub3/bin/subliminal", line 9, in <module>
load_entry_point('subliminal==0.8.0-dev', 'console_scripts', 'subliminal')()
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/cli.py", line 172, in subliminal
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/video.py", line 357, in scan_videos
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/video.py", line 211, in scan_video
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/video.py", line 175, in scan_subtitle_languages
TypeError: 'LanguageConverterManager' object is not callable
It seems to be a babelfish API issue. I won't dig more in that, I let you fix it which should be easy for you.
Just replace get_language_converter('something')
with language_converters['something']
I fixed it locally already but I didn't push yet.
It works (I didn't try with []
before). Now I got a new bug related to python 3 I guess :
(sub3)hadim boromir ~ $ subliminal -v Incoming/movies/The.Hobbit.The.Desolation.Of.Smaug.2013/ -l fr
INFO [subliminal.video] Scanning directory '/home/hadim/Incoming/movies/The.Hobbit.The.Desolation.Of.Smaug.2013'
INFO [subliminal.video] Scanning video 'The.Hobbit.The.Desolation.Of.Smaug.2013.mp4' in '/home/hadim/Incoming/movies/The.Hobbit.The.Desolation.Of.Smaug.2013'
INFO [subliminal.api] Listing subtitles for <Movie ['The Hobbit The Desolation Of Smaug', 2013]>
INFO [subliminal.providers] Listing subtitles with provider 'podnapisi' and languages {<Language [fr]>}
INFO [subliminal.providers] Found 2 subtitles
INFO [subliminal.providers] Listing subtitles with provider 'opensubtitles' and languages {<Language [fr]>}
INFO [subliminal.providers] Found 0 subtitles
INFO [subliminal.providers] Skipping provider 'tvsubtitles': not a valid video
INFO [subliminal.providers] Listing subtitles with provider 'thesubdb' and languages {<Language [fr]>}
INFO [subliminal.providers] Found 0 subtitles
INFO [subliminal.providers] Skipping provider 'addic7ed': not a valid video
INFO [subliminal.api] Found 2 subtitles total
INFO [subliminal.subtitle] Computed score 20 with matches {'title', 'year'}
INFO [subliminal.subtitle] Computed score 20 with matches {'title', 'year'}
Traceback (most recent call last):
File "/home/hadim/local/virtualenvs/sub3/bin/subliminal", line 9, in <module>
load_entry_point('subliminal==0.8.0-dev', 'console_scripts', 'subliminal')()
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/cli.py", line 180, in subliminal
File "/home/hadim/local/virtualenvs/sub3/lib/python3.3/site-packages/subliminal-0.8.0_dev-py3.3.egg/subliminal/api.py", line 90, in download_best_subtitles
TypeError: unorderable types: int() < NoneType()
Or latest guessit
?
I fixed the bug. ere you have the new diff I use. Subliminal seems to work with python 3.3 now (more test are obviously needed) and I also didn't try the diff with python 2.7...
(sub3)hadim boromir subliminal (master *) $ git diff
diff --git a/subliminal/api.py b/subliminal/api.py
index 48f19bf..ed76c03 100644
--- a/subliminal/api.py
+++ b/subliminal/api.py
@@ -87,7 +87,7 @@ def download_best_subtitles(videos, languages, providers=None, provider_confi
downloaded_languages = set()
for subtitle, score in sorted([(s, s.compute_score(video)) for s in video_subtitle
key=operator.itemgetter(1), reverse=True):
- if score < min_score:
+ if score and min_score and (score < min_score):
logger.info('No subtitle with score >= %d', min_score)
break
if subtitle.hearing_impaired != hearing_impaired:
diff --git a/subliminal/cli.py b/subliminal/cli.py
index 81ea305..0fc0d15 100644
--- a/subliminal/cli.py
+++ b/subliminal/cli.py
@@ -77,7 +77,7 @@ def subliminal():
# parse paths
try:
- args.paths = [os.path.abspath(os.path.expanduser(p.decode('utf-8'))) for p in args.pat
+ args.paths = [os.path.abspath(os.path.expanduser(p)) for p in args.paths]
except UnicodeDecodeError:
parser.error('argument paths: encodings is not utf-8: %r' % args.paths)
diff --git a/subliminal/providers/opensubtitles.py b/subliminal/providers/opensubtitles.py
index b040424..12ca0cf 100644
--- a/subliminal/providers/opensubtitles.py
+++ b/subliminal/providers/opensubtitles.py
@@ -82,7 +82,7 @@ class OpenSubtitlesSubtitle(Subtitle):
class OpenSubtitlesProvider(Provider):
- languages = {babelfish.Language.fromopensubtitles(l) for l in babelfish.get_language_conve
+ languages = {babelfish.Language.fromopensubtitles(l) for l in babelfish.language_converter
def __init__(self):
self.server = ServerProxy('http://api.opensubtitles.org/xml-rpc', transport=TimeoutTra
diff --git a/subliminal/providers/podnapisi.py b/subliminal/providers/podnapisi.py
index 4232d6b..726be7c 100644
--- a/subliminal/providers/podnapisi.py
+++ b/subliminal/providers/podnapisi.py
@@ -65,7 +65,7 @@ class PodnapisiSubtitle(Subtitle):
class PodnapisiProvider(Provider):
- languages = {babelfish.Language.frompodnapisi(l) for l in babelfish.get_language_converter
+ languages = {babelfish.Language.frompodnapisi(l) for l in babelfish.language_converters['p
video_types = (Episode, Movie)
server = 'http://simple.podnapisi.net'
link_re = re.compile('^.*(?P<link>/ppodnapisi/download/i/\d+/k/.*$)')
diff --git a/subliminal/video.py b/subliminal/video.py
index cbe06c4..17b860a 100644
--- a/subliminal/video.py
+++ b/subliminal/video.py
@@ -172,7 +172,7 @@ def scan_subtitle_languages(path):
:rtype: set
"""
- language_extensions = tuple('.' + c for c in babelfish.get_language_converter('alpha2').co
+ 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):
@@ -376,13 +376,13 @@ def hash_opensubtitles(video_path):
filehash = filesize
if filesize < 65536 * 2:
return None
- for _ in range(65536 / bytesize):
+ for _ in range(int(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(int(65536 / bytesize)):
filebuffer = f.read(bytesize)
(l_value,) = struct.unpack(b'q', filebuffer)
filehash += l_value
@@ -406,4 +406,4 @@ def hash_thesubdb(video_path):
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()
(I didn't use PR because changes are very minimal here)
Basic python 3 support seems to work now (one commit missing to add better new babelfish support).
I close this issue (since it's becoming very long) and we should open new issue to report python 3 related bug (tagged with py3 maybe?)
Can anyone reproduce https://travis-ci.org/Diaoul/subliminal/jobs/17725492#L324 ?
Should be fixed with f3eaad8d1c3b16ad386c10165f12efb9236fb729 but I can't reproduce the original warning.
can't reproduce it...
I did reproduce it by running python3 setup.py test
. Even with the "fix".
I can't find much documentation about this, any help is appreciated here.
When working on python2/3 compatible code, people often redefined basic python string related type.
If you add this code to guessit/patterns.py :
try:
unicode = unicode
except NameError:
# 'unicode' is undefined, must be Python 3
str = str
unicode = str
bytes = bytes
basestring = (str,bytes)
else:
# 'unicode' exists, must be Python 2
str = str
unicode = unicode
bytes = str
basestring = basestring
Then all test pass. I would suggest you to create a compat.py module in guessit (should be smart to add it to subliminal too) where you put the above code and then you import it in other python files : from .compat import *
Python 3 support does not seem to work: