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


Python YDStreamExtractor.mightHaveVideo方法代码示例

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


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

示例1: hasMedia

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
 def hasMedia(self, count_link_images=False):
     images = False
     video = False
     for l in self.links():
         if l.isImage():
             images = True
         if count_link_images and l.textIsImage():
             images = True
         elif StreamExtractor.mightHaveVideo(l.url) or StreamExtractor.mightHaveVideo(l.text):
             video = True
     if not images:
         images = bool(self.imageURLs())
     return images, video
开发者ID:ruuk,项目名称:script.forum.browser,代码行数:15,代码来源:forumbrowser.py

示例2: handlePush

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
def handlePush(data, from_gui=False):
    if not from_gui and checkForWindow():  # Do nothing if the window is open
        return False
    if data.get("type") == "link":
        url = data.get("url", "")
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info["title"] or "?")
                    idx = xbmcgui.Dialog().select(util.T(32091), vlist)
                    if idx < 0:
                        return
                    vid.selectStream(idx)
                util.LOG(vid.streamURL())  # TODO: REMOVE
                StreamUtils.play(vid.streamURL())
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == "video" or media == "music":
            StreamUtils.play(url)
            return True
        elif media == "image":
            import gui

            gui.showImage(url)
            return True
    elif data.get("type") == "file":
        if data.get("file_type", "").startswith("image/"):
            import gui

            gui.showImage(data.get("file_url", ""))
            return True
        elif data.get("file_type", "").startswith("video/") or data.get("file_type", "").startswith("audio/"):
            StreamUtils.play(data.get("file_url", ""))
            return True
    elif data.get("type") == "note":
        import gui

        gui.showNote(data.get("body", ""))
        return True
    elif data.get("type") == "list":
        import gui

        gui.showList(data)
        return True
    elif data.get("type") == "address":
        import urllib

        xbmc.executebuiltin(
            "XBMC.RunScript(special://home/addons/service.pushbullet.com/lib/maps.py,service.pushbullet.com,%s,None,)"
            % urllib.quote(data.get("address", ""))
        )
        return True

    return False
开发者ID:ruuk,项目名称:service.pushbullet.com,代码行数:62,代码来源:pushhandler.py

示例3: handlePush

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
def handlePush(data, from_gui=False):
    if not from_gui and checkForWindow():  # Do nothing if the window is open
        return False
    if data.get("type") == "link":
        url = data.get("url", "")
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info["title"] or "?")
                    idx = xbmcgui.Dialog().select(common.localise(32091), vlist)
                    if idx < 0:
                        return
                    vid.selectStream(idx)
                playMedia(vid.streamURL(), vid.title, vid.thumbnail, vid.description)
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == "video" or media == "audio":
            url += "|" + urllib.urlencode({"User-Agent": getURLUserAgent(url)})
            playMedia(url, playlist_type="video" and xbmc.PLAYLIST_VIDEO or xbmc.PLAYLIST_MUSIC)
            return True
        elif media == "image":
            import gui

            gui.showImage(url)
            return True
    elif data.get("type") == "file":
        if data.get("file_type", "").startswith("image/"):
            import gui

            gui.showImage(data.get("file_url", ""))
            return True
        elif data.get("file_type", "").startswith("video/") or data.get("file_type", "").startswith("audio/"):
            playMedia(data.get("file_url", ""))
            return True
    elif data.get("type") == "note":
        import gui

        gui.showNote(data.get("body", ""))
        return True
    elif data.get("type") == "list":
        import gui

        gui.showList(data)
        return True
    elif data.get("type") == "address":
        cmd = "XBMC.RunScript({0},MAP,{1},None,)".format(common.__addonid__, urllib.quote(data.get("address", "")))
        xbmc.executebuiltin(cmd)
        return True

    return False
开发者ID:rjof,项目名称:xbmc.service.pushbullet,代码行数:58,代码来源:pushhandler.py

示例4: handlePush

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
def handlePush(data,from_gui=False):
    if not from_gui and checkForWindow(): #Do nothing if the window is open
        return False
    if data.get('type') == 'link':
        url = data.get('url','')
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info['title'] or '?')
                    idx = xbmcgui.Dialog().select(common.localise(32091),vlist)
                    if idx < 0: return
                    vid.selectStream(idx)
                playMedia(vid.streamURL(),vid.title,vid.thumbnail,vid.description)
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == 'video' or media == 'audio':
            url += '|' + urllib.urlencode({'User-Agent':getURLUserAgent(url)})
            playMedia(url,playlist_type='video' and xbmc.PLAYLIST_VIDEO or xbmc.PLAYLIST_MUSIC)
            return True
        elif media == 'image':
            import gui
            gui.showImage(url)
            return True
    elif data.get('type') == 'file':
        if data.get('file_type','').startswith('image/'):
            import gui
            gui.showImage(data.get('file_url',''))
            return True
        elif data.get('file_type','').startswith('video/') or data.get('file_type','').startswith('audio/'):
            playMedia(data.get('file_url',''))
            return True
    elif data.get('type') == 'note':
        import gui
        gui.showNote(data.get('body',''))
        return True
    elif data.get('type') == 'list':
        import gui
        gui.showList(data)
        return True
    elif data.get('type') == 'address':
        cmd = 'XBMC.RunScript({0},MAP,{1},None,)'.format(common.__addonid__,urllib.quote(data.get('address','')))
        xbmc.executebuiltin(cmd)
        return True

    return False
开发者ID:ruuk,项目名称:xbmc.service.pushbullet,代码行数:53,代码来源:pushhandler.py

示例5: canHandle

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
def canHandle(data):
    if data.get('type') == 'link':
        url = data.get('url','')
        if StreamExtractor.mightHaveVideo(url): return 'video'
        mediaType = getURLMediaType(url)
        if mediaType: return mediaType
        return canPlayURL(url) and 'video' or None
    elif data.get('type') == 'file':
        fType = data.get('file_type','')[:5]
        if fType in ('image','video','audio'): return fType
    elif data.get('type') == 'note':
        return 'note'
    elif data.get('type') == 'list':
        return 'list'
    elif data.get('type') == 'address':
        return 'address'
    return None
开发者ID:ruuk,项目名称:xbmc.service.pushbullet,代码行数:19,代码来源:pushhandler.py

示例6: canHandle

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
def canHandle(data):
    if data.get("type") == "link":
        url = data.get("url", "")
        if StreamExtractor.mightHaveVideo(url):
            return "video"
        mediaType = getURLMediaType(url)
        if mediaType:
            return mediaType
        return canPlayURL(url) and "video" or None
    elif data.get("type") == "file":
        fType = data.get("file_type", "")[:5]
        if fType in ("image", "video", "audio"):
            return fType
    elif data.get("type") == "note":
        return "note"
    elif data.get("type") == "list":
        return "list"
    elif data.get("type") == "address":
        return "address"
    return None
开发者ID:rjof,项目名称:xbmc.service.pushbullet,代码行数:22,代码来源:pushhandler.py

示例7: canHandle

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
def canHandle(data):
    if data.get("type") == "link":
        url = data.get("url", "")
        if StreamExtractor.mightHaveVideo(url):
            return True
        if getURLMediaType(url):
            return True
        return canPlayURL(url)
    elif data.get("type") == "file":
        return (
            data.get("file_type", "").startswith("image/")
            or data.get("file_type", "").startswith("audio/")
            or data.get("file_type", "").startswith("video/")
        )
    elif data.get("type") == "note":
        return True
    elif data.get("type") == "list":
        return True
    elif data.get("type") == "address":
        return True
    return False
开发者ID:ruuk,项目名称:service.pushbullet.com,代码行数:23,代码来源:pushhandler.py

示例8: onInit

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
	def onInit(self):
		BaseWindow.onInit(self)
		self.setProperty('loading','1')
		self._winID = xbmcgui.getCurrentWindowId()
		self.pushList = self.getControl(101)
		token = util.getSetting('token')
		if not token: return
		
		loadVideoThumbs = util.getSetting('load_video_thumbs',False)
		kodiDevice = devices.getDefaultKodiDevice(util.getSetting('device_iden'),util.getSetting('device_name'))
		if not kodiDevice: return
		self.pushes = []
		pushes = self.client.pushes()
		if not pushes: return
		items = []
		cacheIDs = []
		self.pushes = []

		for p in pushes: #Keep all IDs cached so that we don't cause a delay when changing view
			if p.get('active'):
				cacheIDs.append(p.get('iden'))

		if self.viewMode == 'SELF':
			self.pushes = [p for p in pushes if p.get('active') and p.get('target_device_iden') == kodiDevice.ID]
		elif self.viewMode == 'ALL':
			self.pushes = [p for p in pushes if p.get('active')]
		elif self.viewMode:
			self.pushes = [p for p in pushes if p.get('active') and p.get('target_device_iden') == self.viewMode]

		for push in self.pushes:
			iden = push.get('iden')

			title = push.get('title',push.get('name',push.get('file_name','')))
			bg = push.get('image_url','')
			info = push.get('url','')
			mediaIcon = ''
			media = ''

			if push.get('type') == 'address':
				bg = maps.Maps().getMap(urllib.quote(push.get('address','')),'None',marker=True,return_url_only=True)
			elif push.get('type') == 'link':
				url = push.get('url')
				if StreamExtractor.mightHaveVideo(url):
					media = 'video'
					if loadVideoThumbs:
						bg = getCachedData(iden)
						if not bg:
							bg = StreamExtractor.getVideoInfo(url).thumbnail
							cacheData(iden,bg)
				else:
					media = pushhandler.getURLMediaType(url)
				if not title:
					title = url.rsplit('/',1)[-1]
			elif push.get('type') == 'file':
				info = urllib.unquote(push.get('file_url',''))
				if push.get('file_type','').startswith('image/'):
					media = 'image'
				elif push.get('file_type','').startswith('audio/'):
					media = 'music'
				elif push.get('file_type','').startswith('video/'):
					media = 'video'
			if media:
				mediaIcon = 'service-pushbullet-com-icon_{0}.png'.format(media)

			item = xbmcgui.ListItem(title,iconImage='service-pushbullet-com-{0}.png'.format(push.get('type','')))

			desc = push.get('body',push.get('address',''))
			if push.get('type') == 'list':
				li = []
				ct = 0
				for i in push.get('items',[]):
					li.append(i.get('text',''))
					ct+=1
					if ct > 50: break
				desc = ', '.join(li)
			desc = '[CR]'.join(desc.splitlines()[:4])
			item.setProperty('description',desc)
			item.setProperty('info',info)
			item.setProperty('sender', push.get('sender_email',''))
			item.setProperty('media_icon',mediaIcon)
			item.setProperty('background',bg)
			#item.setProperty('date',time.strftime('%m-%d-%Y %H:%M',time.localtime(push.get('created',0))))
			item.setProperty('date','{0} {1}'.format(util.durationToShortText(time.time() - push.get('created',0)),T(32053)))
			items.append(item)

		self.setProperty('loading','0')
		self.pushList.reset()
		self.pushList.addItems(items)

		if items: self.setFocusId(101)
		self.reSelect()
		cleanCache(cacheIDs)
开发者ID:ruuk,项目名称:service.pushbullet.com,代码行数:94,代码来源:gui.py

示例9: onInit

# 需要导入模块: import YDStreamExtractor [as 别名]
# 或者: from YDStreamExtractor import mightHaveVideo [as 别名]
    def onInit(self):
        BaseWindow.onInit(self)
        self.setProperty("loading", "1")
        self._winID = xbmcgui.getCurrentWindowId()
        self.pushList = self.getControl(101)
        token = util.getSetting("pb_access_token")
        if not token:
            return

        loadVideoThumbs = util.getSetting("load_video_thumbs", False)
        kodiDevice = devices.getDefaultKodiDevice(
            util.getSetting("pb_client_iden"), util.getSetting("pb_client_nickname")
        )
        if not kodiDevice:
            return
        self.pushes = []
        pushes = self.client.pushes()
        if not pushes:
            return
        items = []
        cacheIDs = []
        self.pushes = []

        for p in pushes:  # Keep all IDs cached so that we don't cause a delay when changing view
            if p.get("active"):
                cacheIDs.append(p.get("iden"))

        if self.viewMode == "SELF":
            self.pushes = [p for p in pushes if p.get("active") and p.get("target_device_iden") == kodiDevice.ID]
        elif self.viewMode == "ALL":
            self.pushes = [p for p in pushes if p.get("active")]
        elif self.viewMode:
            self.pushes = [p for p in pushes if p.get("active") and p.get("target_device_iden") == self.viewMode]

        for push in self.pushes:
            iden = push.get("iden")

            title = push.get("title", push.get("name", push.get("file_name", "")))
            bg = push.get("image_url", "")
            info = push.get("url", "")
            mediaIcon = ""
            media = ""

            if push.get("type") == "address":
                bg = maps.Maps().getMap(
                    urllib.quote(push.get("address", "")), "None", marker=True, return_url_only=True
                )
            elif push.get("type") == "link":
                url = push.get("url")
                if StreamExtractor.mightHaveVideo(url):
                    media = "video"
                    if loadVideoThumbs:
                        bg = getCachedData(iden)
                        if not bg:
                            bg = StreamExtractor.getVideoInfo(url).thumbnail
                            cacheData(iden, bg)
                else:
                    media = pushhandler.getURLMediaType(url)
                if not title:
                    title = url.rsplit("/", 1)[-1]
            elif push.get("type") == "file":
                info = urllib.unquote(push.get("file_url", ""))
                if push.get("file_type", "").startswith("image/"):
                    media = "image"
                elif push.get("file_type", "").startswith("audio/"):
                    media = "music"
                elif push.get("file_type", "").startswith("video/"):
                    media = "video"
            if media:
                mediaIcon = "service-pushbullet-com-icon_{0}.png".format(media)

            item = xbmcgui.ListItem(title, iconImage="service-pushbullet-com-{0}.png".format(push.get("type", "")))

            desc = push.get("body", push.get("address", ""))
            if push.get("type") == "list":
                li = []
                ct = 0
                for i in push.get("items", []):
                    li.append(i.get("text", ""))
                    ct += 1
                    if ct > 50:
                        break
                desc = ", ".join(li)
            desc = "[CR]".join(desc.splitlines()[:4])
            item.setProperty("description", desc)
            item.setProperty("info", info)
            item.setProperty("sender", push.get("sender_name", push.get("sender_email", "")))
            item.setProperty("media_icon", mediaIcon)
            item.setProperty("background", bg)
            # item.setProperty('date',time.strftime('%m-%d-%Y %H:%M',time.localtime(push.get('created',0))))
            item.setProperty(
                "date", "{0} {1}".format(util.durationToShortText(time.time() - push.get("created", 0)), T(32053))
            )
            items.append(item)

        self.setProperty("loading", "0")
        self.pushList.reset()
        self.pushList.addItems(items)

        if items:
#.........这里部分代码省略.........
开发者ID:rattrapper,项目名称:xbmc.service.pushbullet,代码行数:103,代码来源:gui.py


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