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


Python Settings.getOPDSLocation方法代码示例

本文整理汇总了Python中settings.Settings.getOPDSLocation方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getOPDSLocation方法的具体用法?Python Settings.getOPDSLocation怎么用?Python Settings.getOPDSLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在settings.Settings的用法示例。


在下文中一共展示了Settings.getOPDSLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _getRootContents

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getOPDSLocation [as 别名]
    def _getRootContents(self):
        opdsContentsDetails = self._getUrlContents('/opds')

        if opdsContentsDetails not in [None, ""]:
            log("Opds: OPDS Root is %s" % opdsContentsDetails)

            try:
                soup = BeautifulSoup(''.join(opdsContentsDetails))

                # Check to see if there is an icon
                iconElem = soup.find('icon')
                if iconElem not in [None, ""]:
                    if iconElem.string not in [None, ""]:
                        self.rootImage = "%s%s" % (Settings.getOPDSLocation(), iconElem.string)

                # Check each entry, these will be the different view sections
                for elemItem in soup.findAll('entry'):
                    titleElem = elemItem.find('title')
                    if titleElem not in [None, ""]:
                        title = titleElem.string

                        # Not we have the title, get the link associated with the title
                        linkElem = elemItem.find('link')
                        if linkElem not in [None, ""]:
                            linkHref = linkElem['href']
                            log("EBooksPlugin: Found title %s with link %s" % (title, linkHref))
                            self.menuContents[title] = linkElem['href']
            except:
                log("Opds: %s" % traceback.format_exc(), xbmc.LOGERROR)
开发者ID:robwebset,项目名称:script.ebooks,代码行数:31,代码来源:opds.py

示例2: _getUrlContents

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getOPDSLocation [as 别名]
    def _getUrlContents(self, href):
        # Get the server details
        rootOpds = Settings.getOPDSLocation()

        if rootOpds in [None, ""]:
            return

        log("Opds: OPDS Location is %s%s" % (rootOpds, href))

        opdsContentsDetails = None
        try:
            fullURL = href
            if not fullURL.startswith('http'):
                fullURL = "%s%s" % (rootOpds, href)

            # Get the contents list from the library
            remoteOPDSContents = urllib2.urlopen(fullURL)
            opdsContentsDetails = remoteOPDSContents.read()
            # Closes the connection after we have read the remote list
            try:
                remoteOPDSContents.close()
            except:
                log("Opds: Failed to close connection for OPDS contents", xbmc.LOGERROR)
        except:
            log("Opds: Failed to read in OPDS contents: %s" % traceback.format_exc(), xbmc.LOGERROR)

        return opdsContentsDetails
开发者ID:robwebset,项目名称:script.ebooks,代码行数:29,代码来源:opds.py

示例3: getList

# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import getOPDSLocation [as 别名]
    def getList(self, href):
        opdsContentsDetails = self._getUrlContents(href)

        booklist = []
        if opdsContentsDetails not in [None, ""]:
            log("Opds: OPDS Book list is %s" % opdsContentsDetails)

            try:
                soup = BeautifulSoup(''.join(opdsContentsDetails))

                # Check to see if there is an icon
                iconElem = soup.find('icon')
                if iconElem not in [None, ""]:
                    if iconElem.string not in [None, ""]:
                        self.rootImage = "%s%s" % (Settings.getOPDSLocation(), iconElem.string)

                # Check each entry, these will be the different view sections
                for elemItem in soup.findAll('entry'):
                    bookDetails = {'title': '', 'author': '', 'link': '', 'cover': ''}

                    # Get the title of the book
                    titleElem = elemItem.find('title')
                    if titleElem not in [None, ""]:
                        bookDetails['title'] = titleElem.string
                        bookDetails['title'] = bookDetails['title'].replace('&', '&')
                        bookDetails['title'] = bookDetails['title'].replace('&quote;', '"')
                        bookDetails['title'] = bookDetails['title'].replace(' ', ' ')

                    # Get the authods of the book
                    authorElem = elemItem.find('author')
                    if authorElem not in [None, ""]:
                        authors = []
                        for authorName in authorElem.findAll('name'):
                            authors.append(authorName.string)
                        bookDetails['author'] = ', '.join(authors)
                        bookDetails['author'] = bookDetails['author'].replace('&', '&')
                        bookDetails['author'] = bookDetails['author'].replace('&quote;', '"')
                        bookDetails['author'] = bookDetails['author'].replace(' ', ' ')

                    # Get all the links
                    for linkElem in elemItem.findAll('link'):
                        # Check the 'rel' attribute
                        relAttrib = linkElem.get('rel', None)

                        # If there is no rel attribute, then this page is another index page
                        if relAttrib is None:
                            log("Opds: Listing is not books")
                            bookDetails['link'] = linkElem['href']
                            self.isBookList = False
                        else:
                            log("Opds: Listing is books")
                            # Get the link to the book
                            if 'acquisition' in relAttrib:
                                bookLink = "%s%s" % (Settings.getOPDSLocation(), linkElem['href'])
                                # Check if we already have a book
                                if bookDetails.get('link', None) not in [None, '']:
                                    bookLink = Settings.getOPDSPreferredBook(bookDetails['link'], bookLink)

                                bookDetails['link'] = bookLink
                                self.isBookList = True
                            # Get the cover image for the book
                            elif 'cover' in relAttrib:
                                bookDetails['cover'] = "%s%s" % (Settings.getOPDSLocation(), linkElem['href'])

                    booklist.append(bookDetails)

                # Now check to see if there are any more books, as by default it will be paged
                # there is no way to request all books in one go
                nextElem = soup.find('link', {"rel": "next"})
                if nextElem not in [None, ""]:
                    nextPage = nextElem.get('href', None)
                    if nextPage not in [None, ""]:
                        log("Opds: Getting Next page: %s" % nextPage)
                        # Call ourselves again to process the next page
                        nextPageList = self.getList(nextPage)
                        if nextPageList not in [None, ""]:
                            booklist = booklist + nextPageList
            except:
                log("Opds: %s" % traceback.format_exc(), xbmc.LOGERROR)

        return booklist
开发者ID:robwebset,项目名称:script.ebooks,代码行数:83,代码来源:opds.py


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