def subplot(self): subplot = [localizedString(30053)] if hasattr(self, "viewCount"): subplot.append(localizedString(30054)) if hasattr(self, "published"): subplot.append(localizedString(30055)) return "\n".join(subplot)
class User(Item): __plot__ = localizedString(30054) @property def livestream(self): return Livestream(self["livestream"]) @property def pastBroadcasts(self): vods = self.get("pastBroadcasts", {}) return PastBroadcasts(vods.get("list", []), category=self.displayname, **vods.get("pageInfo", {})) @property def followers(self): return self.get("followers", {}).get("totalCount", 0) @property def thumbnail(self): return self.avatar or "DefaultArtist.png" def getItem(self, url, action): return ListItem( self.displayname, buildUrl(url, action=action, username=self.username), isFolder=True, infos={"video": { "title": self.displayname, "plot": self.plot }}, poster=self.thumbnail, thumb=self.thumbnail)
def sortBy(sort_by="relevance"): keys = list(__sortBy__.keys()) index = selectDialog( [localizedString(value) for value in __sortBy__.values()], heading=30130, preselect=keys.index(sort_by)) if index >= 0: sort_by = keys[index] return sort_by
class PastBroadcast(Video): __plot__ = localizedString(30056) def makeItem(self, path): item = super().makeItem(path) item.addStreamInfo("video", {"duration": self.length}) return item def getItem(self, *args): return self.makeItem(self.playbackUrl)
def __makeItem__(label, url, art=None, isFolder=True, **kwargs): label = localizedString(label) return ListItem( label, buildUrl(url, **kwargs), isFolder=isFolder, isPlayable=False, infos={"video": {"title": label, "plot": label}}, poster=art, icon=art )
class Livestream(Video): __plot__ = localizedString(30055) @property def infos(self): return dict(self.__infos__, playcount=0) #def makeItem(self, path): # item = super().makeItem(path) # item.setLabel(f"[COLOR red][LIVE][/COLOR] {self.title}") # return item def getItem(self, url, action): return self.makeItem( buildUrl(url, action=action, username=self.creator.username))
class Category(Item): __plot__ = localizedString(30053) @property def thumbnail(self): return self.imgUrl or "DefaultGenre.png" def getItem(self, url, action): return ListItem( self.title, buildUrl(url, action=action, categoryID=self.backendID), isFolder=True, infos={"video": { "title": self.title, "plot": self.plot }}, poster=self.thumbnail, thumb=self.thumbnail)
class Playlist(Item): __plot__ = localizedString(30061) @property def thumbnail(self): return Url(self.playlistThumbnail) or "DefaultPlaylist.png" def getItem(self, url, action): return ListItem( self.title, buildUrl(url, action=action, playlistId=self.playlistId), isFolder=True, infos={"video": { "title": self.title, "plot": self.plot }}, poster=self.thumbnail, thumb=self.thumbnail)
def rating(self): return localizedString(30052) if self.ageRestriction else ""
class Video(Item): __transform__ = {"videoThumbnails": VideoThumbnails} __date__ = {"published"} __live__ = localizedString(30059) __infos__ = {"mediatype": "video"} __menus__ = [ (30033, "RunScript({addonId},playWithYouTube,{videoId})"), (30031, "RunScript({addonId},goToChannel,{authorId})"), (30032, "RunScript({addonId},addChannelToFavourites,{authorId})"), (30034, "RunScript({addonId},addChannelToFeed,{authorId},{author})") ] @property def liveNow(self): return self.get("liveNow", False) @property def label(self): if self.liveNow: return self.__live__.format(self) return self.title @property def infos(self): if self.liveNow: return dict(self.__infos__, playcount=0) return self.__infos__ @property def subplot(self): subplot = [localizedString(30053)] if hasattr(self, "viewCount"): subplot.append(localizedString(30054)) if hasattr(self, "published"): subplot.append(localizedString(30055)) return "\n".join(subplot) @property def plot(self): plot = ["{0.title}", self.subplot] if hasattr(self, "description"): plot.append("{0.description}") return "\n\n".join(plot).format(self) @property def thumbnail(self): return getattr(self.videoThumbnails, "high", "DefaultAddonVideo.png") def makeItem(self, path): return ListItem( self.label, path, infos={ "video": dict(self.infos, title=self.title, plot=self.plot) }, streamInfos={"video": { "duration": self.lengthSeconds }}, contextMenus=self.menus(authorId=self.authorId, author=self.author, videoId=self.videoId), thumb=self.thumbnail) def getItem(self, url, action): return self.makeItem(buildUrl(url, action=action, videoId=self.videoId))