当前位置: 首页>>代码示例>>Python>>正文


Python Filter.genFilter方法代码示例

本文整理汇总了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
开发者ID:chick3n,项目名称:pchMediaGen,代码行数:37,代码来源:Content.py

示例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
开发者ID:chick3n,项目名称:pchMediaGen,代码行数:40,代码来源:Content.py

示例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
开发者ID:chick3n,项目名称:pchMediaGen,代码行数:40,代码来源:Content.py


注:本文中的Filter.Filter.genFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。