本文整理汇总了Python中Filter.Filter.genFilter方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.genFilter方法的具体用法?Python Filter.genFilter怎么用?Python Filter.genFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter.Filter
的用法示例。
在下文中一共展示了Filter.genFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_movies
# 需要导入模块: from Filter import Filter [as 别名]
# 或者: from Filter.Filter import genFilter [as 别名]
def get_movies(self, page=0, limit=5, filter=None, order='m.title ASC'):
sql = "select m.title, m.description, m.airdate, m.full_path, m.parent_dir, m.added, m.id, datetime(m.watched, 'localtime'), m.runtime, m.poster from movie m"
if filter is not None:
_f = Filter("movie", {"movie": "m"})
sql += _f.genFilter(filter)
sql += " ORDER BY %s LIMIT ?, ?" % order
movies = self.sql.select(sql, (page * limit, limit,))
html = []
for movie in movies:
content = {}
content["id"] = movie[6]
content["title"] = movie[0] if movie[0] is not None else movie[4]
content["desc"] = movie[1] if not movie[1] is None else ""
content["path"] = "file:///opt/sybhttpd/localhost.drives/NETWORK_SHARE/mediaui/Movies/%s" % (movie[3])
content["fanart"] = movie[9] if movie[9] is not None else "movie_fanart.png"
content["added"] = self.convert_date_to_dayssince(movie[5])
content["watchedicon"] = "/images/unwatched.png" if movie[7] is None else "/images/watched.png"
content["watcheddate"] = self.convert_watched_to_dayssince(movie[7])
content["fulltitle"] = content["title"]
content["runtime"] = self.convert_runtime_seconds(movie[8])
content["year"] = self.strip_year_from_date(movie[2])
if content["desc"].__len__() > 300:
content["desc"] = content["desc"][:300] + "..."
if content["title"].__len__() > 30:
content["title"] = content["title"][:30] + "..."
html.append(content)
return html
示例2: get_tv_shows_html
# 需要导入模块: from Filter import Filter [as 别名]
# 或者: from Filter.Filter import genFilter [as 别名]
def get_tv_shows_html(self, page=0, limit=5, f=None):
sql = """
SELECT s.title, s.fanart
, (select count(e.id) from episode e where e.show = s.id)
, (select group_concat(distinct e2.season) from episode e2 where e2.show = s.id)
, s.id
, (select MAX(e3.added) from episode e3 where e3.show = s.id order by e3.added DESC)
FROM show s
"""
if f is not None:
_f = Filter("tv", {"episode": None, "show": "s"})
sql += _f.genFilter(f)
sql += " ORDER BY s.title ASC LIMIT ?, ?"
results = self.sql.select(sql, (page * limit, limit,))
content = {
"shows": []
, "total": 0
, "page": page
}
for result in results:
content["shows"].append(
{
"fulltitle": result[0] #title
, "fanart": result[1] if result[1] is not None else "tv_fanart.png" #fanart
, "epscount": result[2] #episode count
, "shorttitle": result[0][:30]
, "seasons": sorted(result[3].split(","), key=int) if result[3] is not None else ""
, "id": result[4]
, "lastadded": self.convert_date_to_dayssince(result[5])
}
)
return content
示例3: get_latest_tv
# 需要导入模块: from Filter import Filter [as 别名]
# 或者: from Filter.Filter import genFilter [as 别名]
def get_latest_tv(self, page=0, limit=5, _filter=None):
sql = """
select s.title, e.season, e.episode, e.title, e.full_path, e.file_name, e.description, e.added
,s.fanart, s.banner, s.poster, datetime(e.watched, 'localtime'), e.id
from episode e
inner join show s on s.id = e.show
"""
if _filter is not None:
f = Filter("tv", {"episode": "e", "show": "s"})
sql += f.genFilter(_filter)
sql += """
order by added desc
limit ?, ?"""
episodes = self.sql.select(sql, (page * limit, limit,))
content = []
for episode in episodes:
content.append(
{"show": episode[0]
, "season": episode[1]
, "episode": episode[2]
, "title": episode[3]
, "full_path": episode[4]
, "file_name": episode[5]
, "desc": episode[6]
, "added": episode[7]
, "fanart": episode[8]
, "banner": episode[9]
, "poster": episode[10]
, "watched": episode[11]
, "id": episode[12]
}
)
return content