mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
update guessit and subliminal libs. Fixes #678
This commit is contained in:
parent
ff50e5144c
commit
f716323b76
72 changed files with 9350 additions and 3032 deletions
|
@ -2,7 +2,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# GuessIt - A library for guessing information from filenames
|
||||
# Copyright (c) 2011 Nicolas Wack <wackou@gmail.com>
|
||||
# Copyright (c) 2013 Nicolas Wack <wackou@gmail.com>
|
||||
#
|
||||
# GuessIt is free software; you can redistribute it and/or modify it under
|
||||
# the terms of the Lesser GNU General Public License as published by
|
||||
|
@ -18,7 +18,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
from guessit import s, u
|
||||
import os.path
|
||||
import zipfile
|
||||
|
@ -44,17 +45,13 @@ def split_path(path):
|
|||
result = []
|
||||
while True:
|
||||
head, tail = os.path.split(path)
|
||||
headlen = len(head)
|
||||
|
||||
# on Unix systems, the root folder is '/'
|
||||
if head and head == '/'*headlen and tail == '':
|
||||
return ['/'] + result
|
||||
if not head and not tail:
|
||||
return result
|
||||
|
||||
# on Windows, the root folder is a drive letter (eg: 'C:\') or for shares \\
|
||||
if ((headlen == 3 and head[1:] == ':\\') or (headlen == 2 and head == '\\\\')) and tail == '':
|
||||
return [head] + result
|
||||
|
||||
if head == '' and tail == '':
|
||||
if not tail and head == path:
|
||||
# Make sure we won't have an infinite loop.
|
||||
result = [head] + result
|
||||
return result
|
||||
|
||||
# we just split a directory ending with '/', so tail is empty
|
||||
|
@ -70,8 +67,8 @@ def split_path(path):
|
|||
def file_in_same_dir(ref_file, desired_file):
|
||||
"""Return the path for a file in the same dir as a given reference file.
|
||||
|
||||
>>> s(file_in_same_dir('~/smewt/smewt.db', 'smewt.settings'))
|
||||
'~/smewt/smewt.settings'
|
||||
>>> s(file_in_same_dir('~/smewt/smewt.db', 'smewt.settings')) == os.path.normpath('~/smewt/smewt.settings')
|
||||
True
|
||||
|
||||
"""
|
||||
return os.path.join(*(split_path(ref_file)[:-1] + [desired_file]))
|
||||
|
@ -85,6 +82,6 @@ def load_file_in_same_dir(ref_file, filename):
|
|||
if p.endswith('.zip'):
|
||||
zfilename = os.path.join(*path[:i + 1])
|
||||
zfile = zipfile.ZipFile(zfilename)
|
||||
return zfile.read('/'.join(path[i + 1:]))
|
||||
return u(zfile.read('/'.join(path[i + 1:])))
|
||||
|
||||
return u(io.open(os.path.join(*path), encoding='utf-8').read())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue