예제 #1
0
 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)
예제 #2
0
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)
예제 #3
0
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
예제 #4
0
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)
예제 #5
0
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
    )
예제 #6
0
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))
예제 #7
0
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)
예제 #8
0
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)
예제 #9
0
 def rating(self):
     return localizedString(30052) if self.ageRestriction else ""
예제 #10
0
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))