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


Python Addon.show_error_dialog方法代码示例

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


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

示例1:

# 需要导入模块: from t0mm0.common.addon import Addon [as 别名]
# 或者: from t0mm0.common.addon.Addon import show_error_dialog [as 别名]
    
    hosts = re.finditer('<div class="site">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(.+?)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<div class="siteparts">\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href="..(.+?)" target="_blank".+?class="user">(.+?)</div>', html, re.DOTALL)
                         
    sources = []

    num = 0
    for s in hosts:
        #print s.groups()
        title, url, percent = s.groups()
        
        if urlresolver.HostedMediaFile(host=title, media_id='xxx'):
            num += 1
            sources.append([title, url, percent])

    if num == 0:
        addon.show_error_dialog(['Sorry, No hosts found.'])
        xbmc.executebuiltin("Dialog.Close(all,true)")
        xbmc.executebuiltin("Action(ParentDir)")
    #elif num == 1:      # only one host available. Play it...
    #    command = 'RunScript(plugin.video.watchseries.eu,%s,?mode=play&url=%s&section=tvshows)' %(sys.argv[1], main_url+url)
    #    xbmc.executebuiltin(command)
    #    xbmc.executebuiltin("Action(ParentDir)")
    #    addon.end_of_directory()
    else:
        for s in sources:
            title = s[0]
            url = s[1]
            percent = s[2]
           
            if addon.get_setting('showpercent') == 'true': outtitle = title + ' - ' + percent
            else: outtitle = title
开发者ID:wjb,项目名称:mscreations-xbmc-addons,代码行数:33,代码来源:default.py

示例2: CraftsyPlugin

# 需要导入模块: from t0mm0.common.addon import Addon [as 别名]
# 或者: from t0mm0.common.addon.Addon import show_error_dialog [as 别名]

#.........这里部分代码省略.........
                url = self.base_url + url
            t = re.search('<h4>([^<]+)</h4>', i[1])
            title = 'N/A'
            title = self.__fetch_regexp_idx(t, 0, 'N/A')
            img = self.base_url + '/images/craftsy/noImageTitleCard.png'
            t = re.search('<img src="([^"]+)" alt="[^"]+" onerror', i[1])
            _u = self.__fetch_regexp_idx(t, 0)
            if (_u != None):
                img = self.__check_link(_u)

            # print self.__get_image(img)
            self.addon.add_directory({'mode': 'classes', 'url': url}, {'title': title}, fanart=img, img=img)

    def __try_resolve(self, pattern, video):
        r = re.search(pattern, video)
        return self.__fetch_regexp_idx(r, 0)

    def resolve_url(self, lesson_url):
        pattern = '&([0-9]+)&(pay|free)$'
        l = re.search(pattern, lesson_url)
        lesson_id = self.__fetch_regexp_idx(l, 0)
        lesson_type = self.__fetch_regexp_idx(l, 1, 'pay')
        lesson_url = re.sub(pattern, '', lesson_url)

        q = self.addon.get_setting('quality')
        t = self.addon.get_setting('type')

        source = self.__get_url(lesson_url)

        uid = re.search('/([0-9]+)\\.html(\\?t=[0-9]*){0,1}$', lesson_url)
        url_id = self.__fetch_regexp_idx(uid, 0)
        if (url_id == None):
            return None

        r = re.search('arbitraryId = ([0-9]+),', source)
        arbitraryId = self.__fetch_regexp_idx(r, 0)
        if (arbitraryId != None):
            url_id = arbitraryId

        suffix = lesson_id + '/' + url_id + '/' + url_id + '-' + q + '.' + t
        if lesson_type == 'free':
            print "THE URL TO PLAY IS " + self.free_url + suffix
            return self.free_url + suffix
        else:
            return self.pay_url + suffix

        # r = re.search('(<video.*?</video>)', source)

        # if (len(r.groups()) == 0):
        #     return None
        # else:
        #     video = r.groups()[0]
        #     video_url = self.__try_resolve('<source src="([^"]+-' + q + '\\.' + t + ')"', video)
        #     if (video_url == None):
        #         video_url = self.__try_resolve('<source src="([^"]+-' + q + '\\.[^\\.]+)"', video)
        #         if (video_url == None):
        #             video_url = self.__try_resolve('<source src="([^"]+)"', video)

        #     return video_url


    def add_lessons(self, class_url):
        source = self.__get_url(class_url) # self.net.http_GET(class_url).content
        l = re.search('\,([0-9]+)$', class_url)
        lesson_id = self.__fetch_regexp_idx(l, 0)
        if (lesson_id == None):
            self.addon.show_error_dialog(['Could not fetch the lesson ID']);
            return None
        r = re.findall('(<tr class="classLesson.*?</tr>)', source)
        first = True
        lesson_type = 'pay'
        for i in r:
            text = i 
            el = re.search('<td class="lessonName">.*?<a href="([^"]+)">(.*?)</a>', text)
            href = self.__fetch_regexp_idx(el, 0)
            if href != None:
                href = self.__check_link(href)
                title = self.__fetch_regexp_idx(el, 1, 'N/A')
                if (first):
                    if (title.lower() == 'welcome to your free mini-class!'):
                        lesson_type = 'free'
                im = re.search('<td class="lessonImage">.*?<img src="([^"]+)"', text)
                img = self.__check_link(self.__fetch_regexp_idx(im, 0, os.path.join(self.addon.get_path(), 'art','no-img.jpg')))

                self.addon.add_video_item({'url': href + '&' + lesson_id + '&' + lesson_type}, {'title': title}, img = img, fanart = img)
            first = False

    def do_login(self):
        try:
            if self.check_login():
                return True
            data=(('email', self.addon.get_setting('username')), ('password', self.addon.get_setting('password')), ('forwardUrl', '/'))
            source = self.net.http_POST(self.base_url + '/doLogin.json?isCraftsyAjax=true', data).content
            response = JSONDecoder().decode(source)
            self.net.save_cookies(self.cookie_file)
            self.net.set_cookies(self.cookie_file)
            return response.get("success")
        except Exception as e:
            print e
            return False
开发者ID:cosminadrianpopescu,项目名称:plugin.video.craftsy,代码行数:104,代码来源:plugin.py


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