This commit is contained in:
j 2017-01-07 12:11:05 +01:00
parent e004a3836e
commit 077c979a41

View file

@ -2,18 +2,19 @@
# vi:si:et:sw=4:sts=4:ts=4
# GPL 2008
from __future__ import division, print_function
import os
from distutils.spawn import find_executable
from glob import glob
import hashlib
import os
import re
import shutil
import sqlite3
import struct
import subprocess
import sqlite3
from distutils.spawn import find_executable
from .utils import json
__all__ = ['sha1sum', 'oshash', 'avinfo', 'makedirs']
__all__ = ['sha1sum', 'oshash', 'avinfo', 'makedirs', 'iexists']
EXTENSIONS = {
'audio': [
@ -229,7 +230,7 @@ def ffprobe(filename):
return value
info = {}
if not 'format' in ffinfo:
if 'format' not in ffinfo:
info['error'] = 'badfile'
else:
for key in ('duration', 'size', 'bit_rate'):
@ -368,3 +369,14 @@ def write_path(file):
path = os.path.split(file)[0]
if path and not os.path.exists(path):
os.makedirs(path)
def iexists(path):
parts = path.split(os.sep)
name = parts[-1].lower()
if len(parts) == 1:
folder = '.'
else:
folder = os.path.dirname(path)
files = os.listdir(folder)
files = {os.path.basename(f).lower() for f in files}
return name in files