本文整理汇总了Python中sickchill.helper.encoding.ek函数的典型用法代码示例。如果您正苦于以下问题:Python ek函数的具体用法?Python ek怎么用?Python ek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ek函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: change_unpack_dir
def change_unpack_dir(unpack_dir):
"""
Change UNPACK directory (used by postprocessor)
:param unpack_dir: New unpack directory
:return: True on success, False on failure
"""
if unpack_dir == '':
sickbeard.UNPACK_DIR = ''
return True
if ek(os.path.normpath, sickbeard.UNPACK_DIR) != ek(os.path.normpath, unpack_dir):
if bool(sickbeard.ROOT_DIRS) and \
any(map(lambda rd: helpers.is_subdirectory(unpack_dir, rd), sickbeard.ROOT_DIRS.split('|')[1:])):
# don't change if it's in any of the TV root directories
logger.log("Unable to change unpack directory to a sub-directory of a TV root dir")
return False
if helpers.makeDir(unpack_dir):
sickbeard.UNPACK_DIR = ek(os.path.normpath, unpack_dir)
logger.log("Changed unpack directory to " + unpack_dir)
else:
logger.log("Unable to create unpack directory " + ek(os.path.normpath, unpack_dir) + ", dir not changed.")
return False
return True
开发者ID:murbaniak,项目名称:SickRage,代码行数:26,代码来源:config.py
示例2: fetch_popular_shows
def fetch_popular_shows(self):
"""Get popular show information from IMDB"""
popular_shows = []
data = helpers.getURL(self.url, session=self.session, params=self.params, headers={'Referer': 'http://akas.imdb.com/'}, returns='text')
if not data:
return None
soup = BeautifulSoup(data, 'html5lib')
results = soup.find("table", {"class": "results"})
rows = results("tr")
for row in rows:
show = {}
image_td = row.find("td", {"class": "image"})
if image_td:
image = image_td.find("img")
show['image_url_large'] = self.change_size(image['src'], 3)
show['image_path'] = ek(posixpath.join, 'images', 'imdb_popular', ek(os.path.basename, show['image_url_large']))
self.cache_image(show['image_url_large'])
td = row.find("td", {"class": "title"})
if td:
show['name'] = td.find("a").contents[0]
show['imdb_url'] = "http://akas.imdb.com" + td.find("a")["href"]
show['imdb_tt'] = show['imdb_url'][-10:][0:9]
show['year'] = td.find("span", {"class": "year_type"}).contents[0].split(" ")[0][1:]
rating_all = td.find("div", {"class": "user_rating"})
if rating_all:
rating_string = rating_all.find("div", {"class": "rating rating-list"})
if rating_string:
rating_string = rating_string['title']
match = re.search(r".* (.*)\/10.*\((.*)\).*", rating_string)
if match:
matches = match.groups()
show['rating'] = matches[0]
show['votes'] = matches[1]
else:
show['rating'] = None
show['votes'] = None
else:
show['rating'] = None
show['votes'] = None
outline = td.find("span", {"class": "outline"})
if outline:
show['outline'] = outline.contents[0]
else:
show['outline'] = ''
popular_shows.append(show)
return popular_shows
开发者ID:murbaniak,项目名称:SickRage,代码行数:59,代码来源:imdb.py
示例3: log_data
def log_data(min_level, log_filter, log_search, max_lines):
regex = r"^(\d\d\d\d)\-(\d\d)\-(\d\d)\s*(\d\d)\:(\d\d):(\d\d)\s*([A-Z]+)\s*(.+?)\s*\:\:\s*(.*)$"
if log_filter not in LOG_FILTERS:
log_filter = '<NONE>'
final_data = []
log_files = []
if ek(os.path.isfile, Wrapper.instance.log_file):
log_files.append(Wrapper.instance.log_file)
for i in range(1, int(sickbeard.LOG_NR)):
name = Wrapper.instance.log_file + "." + str(i)
if not ek(os.path.isfile, name):
break
log_files.append(name)
else:
return final_data
data = []
for _log_file in log_files:
if len(data) < max_lines:
with io.open(_log_file, 'r', encoding='utf-8') as f:
data += [line.strip() + '\n' for line in reversed(f.readlines()) if line.strip()]
else:
break
found_lines = 0
for x in data:
match = re.match(regex, x)
if match:
level = match.group(7)
log_name = match.group(8)
if not sickbeard.DEBUG and level == 'DEBUG':
continue
if not sickbeard.DBDEBUG and level == 'DB':
continue
if level not in LOGGING_LEVELS:
final_data.append('AA ' + x)
found_lines += 1
elif log_search and log_search.lower() in x.lower():
final_data.append(x)
found_lines += 1
elif not log_search and LOGGING_LEVELS[level] >= int(min_level) and (log_filter == '<NONE>' or log_name.startswith(log_filter)):
final_data.append(x)
found_lines += 1
else:
final_data.append('AA ' + x)
found_lines += 1
if found_lines >= max_lines:
break
return final_data
开发者ID:murbaniak,项目名称:SickRage,代码行数:58,代码来源:logger.py
示例4: fill_cache
def fill_cache(self, show_obj):
"""
Caches all images for the given show. Copies them from the show dir if possible, or
downloads them from indexer if they aren't in the show dir.
:param show_obj: TVShow object to cache images for
"""
logger.log("Checking if we need any cache images for show " + str(show_obj.indexerid), logger.DEBUG)
# check if the images are already cached or not
need_images = {self.POSTER: not self.has_poster(show_obj.indexerid),
self.BANNER: not self.has_banner(show_obj.indexerid),
self.POSTER_THUMB: not self.has_poster_thumbnail(show_obj.indexerid),
self.BANNER_THUMB: not self.has_banner_thumbnail(show_obj.indexerid),
self.FANART: not self.has_fanart(show_obj.indexerid)}
if not need_images[self.POSTER] and not need_images[self.BANNER] and not need_images[self.POSTER_THUMB] and not need_images[self.BANNER_THUMB] and not need_images[self.FANART]:
logger.log("No new cache images needed, not retrieving new ones", logger.DEBUG)
return
# check the show dir for poster or banner images and use them
if need_images[self.POSTER] or need_images[self.BANNER] or need_images[self.FANART]:
try:
for cur_provider in sickbeard.metadata_provider_dict.values():
logger.log("Checking if we can use the show image from the " + cur_provider.name + " metadata",
logger.DEBUG)
if ek(os.path.isfile, cur_provider.get_poster_path(show_obj)):
cur_file_name = ek(os.path.abspath, cur_provider.get_poster_path(show_obj))
cur_file_type = self.which_type(cur_file_name)
if cur_file_type is None:
logger.log("Unable to retrieve image type, not using the image from " + str(cur_file_name),
logger.WARNING)
continue
logger.log("Checking if image " + cur_file_name + " (type " + str(
cur_file_type) + " needs metadata: " + str(need_images[cur_file_type]), logger.DEBUG)
if cur_file_type in need_images and need_images[cur_file_type]:
logger.log(
"Found an image in the show dir that doesn't exist in the cache, caching it: " + cur_file_name + ", type " + str(
cur_file_type), logger.DEBUG)
self._cache_image_from_file(cur_file_name, cur_file_type, show_obj.indexerid)
need_images[cur_file_type] = False
except ShowDirectoryNotFoundException:
logger.log("Unable to search for images in show dir because it doesn't exist", logger.WARNING)
# download from indexer for missing ones
for cur_image_type in [self.POSTER, self.BANNER, self.POSTER_THUMB, self.BANNER_THUMB, self.FANART]:
logger.log("Seeing if we still need an image of type " + str(cur_image_type) + ": " + str(
need_images[cur_image_type]), logger.DEBUG)
if cur_image_type in need_images and need_images[cur_image_type]:
self._cache_image_from_indexer(show_obj, cur_image_type)
logger.log("Done cache check")
开发者ID:murbaniak,项目名称:SickRage,代码行数:56,代码来源:image_cache.py
示例5: makeObject
def makeObject(self, cmd_arg, cur_path):
if sickbeard.USE_SYNOINDEX:
synoindex_cmd = ['/usr/syno/bin/synoindex', cmd_arg, ek(os.path.abspath, cur_path)]
logger.log("Executing command " + str(synoindex_cmd), logger.DEBUG)
logger.log("Absolute path to command: " + ek(os.path.abspath, synoindex_cmd[0]), logger.DEBUG)
try:
p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
cwd=sickbeard.PROG_DIR)
out, err = p.communicate() # @UnusedVariable
logger.log("Script result: " + str(out), logger.DEBUG)
except OSError as e:
logger.log("Unable to run synoindex: " + ex(e), logger.ERROR)
开发者ID:murbaniak,项目名称:SickRage,代码行数:12,代码来源:synoindex.py
示例6: retrieveShowMetadata
def retrieveShowMetadata(self, folder):
"""
Used only when mass adding Existing Shows, using previously generated Show metadata to reduce the need to query TVDB.
"""
empty_return = (None, None, None)
assert isinstance(folder, six.text_type)
metadata_path = ek(os.path.join, folder, self._show_metadata_filename)
if not ek(os.path.isdir, folder) or not ek(os.path.isfile, metadata_path):
logger.log("Can't load the metadata file from " + metadata_path + ", it doesn't exist", logger.DEBUG)
return empty_return
logger.log("Loading show info from metadata file in " + metadata_path, logger.DEBUG)
try:
with io.open(metadata_path, 'rb') as xmlFileObj:
showXML = etree.ElementTree(file=xmlFileObj)
if showXML.findtext('title') is None or (showXML.findtext('tvdbid') is None and showXML.findtext('id') is None):
logger.log("Invalid info in tvshow.nfo (missing name or id): {0} {1} {2}".format(showXML.findtext('title'), showXML.findtext('tvdbid'), showXML.findtext('id')))
return empty_return
name = showXML.findtext('title')
indexer_id_text = showXML.findtext('tvdbid') or showXML.findtext('id')
if indexer_id_text:
indexer_id = try_int(indexer_id_text, None)
if indexer_id is None or indexer_id < 1:
logger.log("Invalid Indexer ID (" + str(indexer_id) + "), not using metadata file", logger.DEBUG)
return empty_return
else:
logger.log("Empty <id> or <tvdbid> field in NFO, unable to find a ID, not using metadata file", logger.DEBUG)
return empty_return
indexer = 1
epg_url_text = showXML.findtext('episodeguide/url')
if epg_url_text:
epg_url = epg_url_text.lower()
if str(indexer_id) in epg_url and 'tvrage' in epg_url:
logger.log("Invalid Indexer ID (" + str(indexer_id) + "), not using metadata file because it has TVRage info", logger.WARNING)
return empty_return
except Exception as e:
logger.log(
"There was an error parsing your existing metadata file: '" + metadata_path + "' error: " + ex(e),
logger.WARNING)
return empty_return
return indexer_id, name, indexer
开发者ID:murbaniak,项目名称:SickRage,代码行数:52,代码来源:generic.py
示例7: remove_pid_file
def remove_pid_file(pid_file):
"""
Remove pid file
:param pid_file: to remove
:return:
"""
try:
if ek(os.path.exists, pid_file):
ek(os.remove, pid_file)
except EnvironmentError:
return False
return True
开发者ID:murbaniak,项目名称:SickRage,代码行数:14,代码来源:SickBeard.py
示例8: has_banner_thumbnail
def has_banner_thumbnail(self, indexer_id):
"""
Returns true if a cached banner exists for the given Indexer ID
"""
banner_thumb_path = self.banner_thumb_path(indexer_id)
logger.log("Checking if file " + str(banner_thumb_path) + " exists", logger.DEBUG)
return ek(os.path.isfile, banner_thumb_path)
开发者ID:murbaniak,项目名称:SickRage,代码行数:7,代码来源:image_cache.py
示例9: get_media_path
def get_media_path(self):
show = self.get_show()
if show:
return ek(join, self.get_media_root(), 'images', 'network', show.network_logo_name + '.png')
return ''
开发者ID:murbaniak,项目名称:SickRage,代码行数:7,代码来源:ShowNetworkLogo.py
示例10: has_poster
def has_poster(self, indexer_id):
"""
Returns true if a cached poster exists for the given Indexer ID
"""
poster_path = self.poster_path(indexer_id)
logger.log("Checking if file " + str(poster_path) + " exists", logger.DEBUG)
return ek(os.path.isfile, poster_path)
开发者ID:murbaniak,项目名称:SickRage,代码行数:7,代码来源:image_cache.py
示例11: get_episode_thumb_path
def get_episode_thumb_path(ep_obj):
"""
Returns a full show dir/metadata/episode.jpg path for MediaBrowser
episode thumbs.
ep_obj: a TVEpisode object to get the path from
"""
if ek(os.path.isfile, ep_obj.location):
tbn_file_name = replace_extension(ek(os.path.basename, ep_obj.location), 'jpg')
metadata_dir_name = ek(os.path.join, ek(os.path.dirname, ep_obj.location), 'metadata')
tbn_file_path = ek(os.path.join, metadata_dir_name, tbn_file_name)
else:
return None
return tbn_file_path
开发者ID:murbaniak,项目名称:SickRage,代码行数:16,代码来源:mediabrowser.py
示例12: has_fanart
def has_fanart(self, indexer_id):
"""
Returns true if a cached fanart exists for the given Indexer ID
"""
fanart_path = self.fanart_path(indexer_id)
logger.log("Checking if file " + str(fanart_path) + " exists", logger.DEBUG)
return ek(os.path.isfile, fanart_path)
开发者ID:murbaniak,项目名称:SickRage,代码行数:7,代码来源:image_cache.py
示例13: qualityFromFileMeta
def qualityFromFileMeta(filename): # pylint: disable=too-many-branches
"""
Get quality file file metadata
:param filename: Filename to analyse
:return: Quality prefix
"""
height = video_screen_size(filename)[1]
if not height:
return Quality.UNKNOWN
base_filename = ek(path.basename, filename)
bluray = re.search(r"blue?-?ray|hddvd|b[rd](rip|mux)", base_filename, re.I) is not None
webdl = re.search(r"web.?dl|web(rip|mux|hd)", base_filename, re.I) is not None
ret = Quality.UNKNOWN
if 3240 < height:
ret = ((Quality.UHD_8K_TV, Quality.UHD_8K_BLURAY)[bluray], Quality.UHD_8K_WEBDL)[webdl]
if 1620 < height <= 3240:
ret = ((Quality.UHD_4K_TV, Quality.UHD_4K_BLURAY)[bluray], Quality.UHD_4K_WEBDL)[webdl]
elif 800 < height <= 1620:
ret = ((Quality.FULLHDTV, Quality.FULLHDBLURAY)[bluray], Quality.FULLHDWEBDL)[webdl]
elif 680 < height <= 800:
ret = ((Quality.HDTV, Quality.HDBLURAY)[bluray], Quality.HDWEBDL)[webdl]
elif height <= 680:
ret = (Quality.SDTV, Quality.SDDVD)[re.search(r'dvd|b[rd]rip|blue?-?ray', base_filename, re.I) is not None]
return ret
开发者ID:murbaniak,项目名称:SickRage,代码行数:29,代码来源:common.py
示例14: addDefaultShow
def addDefaultShow(indexer, indexer_id, name, status):
"""
Adds a new show with the default settings
"""
if not Show.find(sickbeard.showList, int(indexer_id)):
logger.log("Adding show " + str(indexer_id))
root_dirs = sickbeard.ROOT_DIRS.split('|')
try:
location = root_dirs[int(root_dirs[0]) + 1]
except Exception:
location = None
if location:
showPath = ek(os.path.join, location, sanitize_filename(name))
dir_exists = helpers.makeDir(showPath)
if not dir_exists:
logger.log("Unable to create the folder {0} , can't add the show".format(showPath), logger.WARNING)
return
else:
helpers.chmodAsParent(showPath)
sickbeard.showQueueScheduler.action.add_show(int(indexer), int(indexer_id), showPath,
default_status=status,
quality=int(sickbeard.QUALITY_DEFAULT),
season_folders=int(sickbeard.SEASON_FOLDERS_DEFAULT),
paused=sickbeard.TRAKT_START_PAUSED,
default_status_after=status)
else:
logger.log("There was an error creating the show, no root directory setting found", logger.WARNING)
return
开发者ID:murbaniak,项目名称:SickRage,代码行数:32,代码来源:traktChecker.py
示例15: _check_exists
def _check_exists(location):
if location:
assert isinstance(location, six.text_type)
result = ek(os.path.isfile, location)
logger.log("Checking if " + location + " exists: " + str(result), logger.DEBUG)
return result
return False
开发者ID:murbaniak,项目名称:SickRage,代码行数:7,代码来源:generic.py
示例16: fetch_popular_shows
def fetch_popular_shows(self):
"""Get popular show information from IMDB"""
popular_shows = []
data = helpers.getURL(self.url, session=self.session, params=self.params, headers={'Referer': 'http://akas.imdb.com/'}, returns='text')
if not data:
return None
soup = BeautifulSoup(data, 'html5lib')
results = soup.find_all("div", {"class": "lister-item"})
for row in results:
show = {}
image_div = row.find("div", {"class": "lister-item-image"})
if image_div:
image = image_div.find("img")
show['image_url_large'] = self.change_size(image['loadlate'], 3)
show['imdb_tt'] = image['data-tconst']
show['image_path'] = ek(posixpath.join, 'images', 'imdb_popular', ek(os.path.basename, show['image_url_large']))
self.cache_image(show['image_url_large'])
content = row.find("div", {"class": "lister-item-content"})
if content:
header = row.find("h3", {"class": "lister-item-header"})
if header:
a_tag = header.find("a")
if a_tag:
show['name'] = a_tag.get_text(strip=True)
show['imdb_url'] = "http://www.imdb.com" + a_tag["href"]
show['year'] = header.find("span", {"class": "lister-item-year"}).contents[0].split(" ")[0][1:].strip("-")
imdb_rating = row.find("div", {"class": "ratings-imdb-rating"})
show['rating'] = imdb_rating['data-value'] if imdb_rating else None
votes = row.find("span", {"name": "nv"})
show['votes'] = votes['data-value'] if votes else None
outline = content.find_all("p", {"class": "text-muted"})
if outline and len(outline) >= 2:
show['outline'] = outline[1].contents[0].strip("\"")
else:
show['outline'] = ''
popular_shows.append(show)
return popular_shows
开发者ID:murbaniak,项目名称:SickRage,代码行数:47,代码来源:imdbPopular.py
示例17: api_params
def api_params(self):
if self.indexerID:
if sickbeard.CACHE_DIR:
indexerConfig[self.indexerID]['api_params']['cache'] = ek(os.path.join, sickbeard.CACHE_DIR, 'indexers', self.name)
if sickbeard.PROXY_SETTING and sickbeard.PROXY_INDEXERS:
indexerConfig[self.indexerID]['api_params']['proxy'] = sickbeard.PROXY_SETTING
return indexerConfig[self.indexerID]['api_params']
开发者ID:murbaniak,项目名称:SickRage,代码行数:8,代码来源:indexer_api.py
示例18: change_size
def change_size(image_url, factor=3):
match = re.search("^(.*)V1_(.{2})(.*?)_(.{2})(.*?),(.*?),(.*?),(.\d?)_(.*?)_.jpg$", image_url)
if match:
matches = match.groups()
ek(os.path.basename, image_url)
matches = list(matches)
matches[2] = int(matches[2]) * factor
matches[4] = int(matches[4]) * factor
matches[5] = int(matches[5]) * factor
matches[6] = int(matches[6]) * factor
matches[7] = int(matches[7]) * factor
return "{0}V1._{1}{2}_{3}{4},{5},{6},{7}_.jpg".format(matches[0], matches[1], matches[2], matches[3], matches[4],
matches[5], matches[6], matches[7])
else:
return image_url
开发者ID:murbaniak,项目名称:SickRage,代码行数:17,代码来源:imdbPopular.py
示例19: getFileList
def getFileList(path, includeFiles, fileTypes):
# prune out directories to protect the user from doing stupid things (already lower case the dir to reduce calls)
hide_list = ['boot', 'bootmgr', 'cache', 'config.msi', 'msocache', 'recovery', '$recycle.bin',
'recycler', 'system volume information', 'temporary internet files'] # windows specific
hide_list += ['.fseventd', '.spotlight', '.trashes', '.vol', 'cachedmessages', 'caches', 'trash'] # osx specific
hide_list += ['.git']
file_list = []
dir_list = []
for filename in ek(os.listdir, path):
if filename.lower() in hide_list:
continue
full_filename = ek(os.path.join, path, filename)
is_file = ek(os.path.isfile, full_filename)
if not includeFiles and is_file:
continue
is_image = False
allowed_type = True
if is_file and fileTypes:
if 'images' in fileTypes:
is_image = filename.endswith(('jpg', 'jpeg', 'png', 'tiff', 'gif'))
allowed_type = filename.endswith(tuple(fileTypes)) or is_image
if not allowed_type:
continue
item_to_add = {
'name': filename,
'path': full_filename,
'isFile': is_file,
'isImage': is_image,
'isAllowed': allowed_type
}
if is_file:
file_list.append(item_to_add)
else:
dir_list.append(item_to_add)
# Sort folders first, alphabetically, case insensitive
dir_list.sort(key=lambda mbr: itemgetter('name')(mbr).lower())
file_list.sort(key=lambda mbr: itemgetter('name')(mbr).lower())
return dir_list + file_list
开发者ID:murbaniak,项目名称:SickRage,代码行数:46,代码来源:browser.py
示例20: get_episode_file_path
def get_episode_file_path(self, ep_obj):
"""
Returns a full show dir/metadata/episode.xml path for MediaBrowser
episode metadata files
ep_obj: a TVEpisode object to get the path for
"""
if ek(os.path.isfile, ep_obj.location):
xml_file_name = replace_extension(ek(os.path.basename, ep_obj.location), self._ep_nfo_extension)
metadata_dir_name = ek(os.path.join, ek(os.path.dirname, ep_obj.location), 'metadata')
xml_file_path = ek(os.path.join, metadata_dir_name, xml_file_name)
else:
logger.log("Episode location doesn't exist: " + str(ep_obj.location), logger.DEBUG)
return ''
return xml_file_path
开发者ID:murbaniak,项目名称:SickRage,代码行数:17,代码来源:mediabrowser.py
注:本文中的sickchill.helper.encoding.ek函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论