def setUpClass(cls):
     library.scraper.getshowinfo = fake_getshowinfo
     library.scraper.getinfodict = fake_getepinfo
     library.scraper.getepisodes = fake_getepisodes_return_A
     cls.show = library.Show(urlid="faketvshowurlid", title="The Fake Koala %s Show" % const.provider)
     cls.episodepath = uni_join(const.libpath, "%s shows" % const.provider, "%s\\" % stringtofile(cls.show.title))
     library.execute(to_update_add=[cls.show])
 def setUpClass(cls):
     library.scraper.getepisodes = fake_getepisodes_return_A_B
     cls.show = library.Show(urlid="broadchurch", title="Broadchurch")
     library.execute(to_update_add=[cls.show])
     cls.episodepath = uni_join(const.libpath, "%s shows" % const.provider, "%s\\" % stringtofile(cls.show.title))
     libfiles = [show["file"] for show in rpc("VideoLibrary.GetTVShows", properties=["file"])['tvshows']]
     assert cls.episodepath in libfiles
     library.execute(to_remove=[cls.show])
 def __init__(self, show, seasonnr, episodenr):
     self.showtitle = show.title
     self.seasonnr = int(seasonnr)
     self.episodenr = int(episodenr)
     self.code = "S%02dE%02d" % (seasonnr, episodenr)
     self.path = utils.uni_join(const.libpath, "%s shows" % const.provider,
                                utils.stringtofile(self.showtitle), "Season %s" % self.seasonnr)
     self.htmfilename = "%s %s.htm" % (utils.stringtofile(self.showtitle), self.code)
     self.nfofilename = "%s %s.nfo" % (utils.stringtofile(self.showtitle), self.code)
     self.jsonfilename = "%s %s.json" % (utils.stringtofile(self.showtitle), self.code)
    def setup(self):
        playingfile = self.get_playing_file()
        if not playingfile["file"].startswith((utils.uni_join(const.libpath, const.provider),
                                               utils.uni_join(const.addonpath, "resources"))):
            return
        try:
            kodi.log("Start playback setup")

            self.player = Player(stop_event=self.stop_event)

            if kodi.settings["remote"]:
                self.remote = remote.Remote()
                self.remote.run(player=self.player)

            self.player.connect()

            if playingfile["type"] == "episode":
                Thread(target=self.monitor_episodes_progress, args=[playingfile]).start()
            elif playingfile["type"] == "movie":
                Thread(target=self.monitor_movie_progress, args=[playingfile]).start()

            kodi.log("Finished playback setup")

        except self.player.exceptions:
            pass

        except:
            kodi.log("Exception occured during playback\n%s" % traceback.format_exc().decode(sys.getfilesystemencoding()))

        finally:
            self.stop_event.wait()

            kodi.log("Start playback cleanup")
            if self.remote:
                self.remote.close()
            if self.player:
                self.player.disconnect()
            kodi.log("Finish playback cleanup")
Esempio n. 5
0
def library_mode(action):
    if xbmcgui.Window(10000).getProperty("%s running" % const.addonname) == "true":
        if action in ["startup", "schedule"]:
            return
        run = kodi.Dialog.yesno(heading="Running", line1="Koala is running. ",
                                line2="Running multiple instances may cause instablity.", line3="Continue?")
        if not run:
            return
    koalasetup()
    if not is_libpath_added():
        kodi.Dialog.ok(heading="Koala path not in video sources",
                       line1="Koala library paths have not been added to Kodi video sources:",
                       line2=utils.uni_join(const.libpath, "%s shows" % const.provider),
                       line3=utils.uni_join(const.libpath, "%s movies" % const.provider))
        return

    starttime = dt.datetime.now()
    kodi.log("Starting %s" % action)
    xbmcgui.Window(10000).setProperty("%s running" % const.addonname, "true")
    try:
        library.main(action)
    finally:
        xbmcgui.Window(10000).setProperty("%s running" % const.addonname, "false")
        kodi.log("Finished %s in %s" % (action, str(dt.datetime.now() - starttime)))
Esempio n. 6
0
def is_libpath_added():
    sources = kodi.rpc("Files.GetSources", media="video")
    for source in sources.get('sources', []):
        if source['file'].startswith(utils.uni_join(const.libpath, const.provider)):
            return True
    return False
 def __init__(self, title):
     self.title = title
     self.path = utils.uni_join(const.libpath, "%s movies" % const.provider)
     self.htmfilename = "%s.htm" % utils.stringtofile(self.title)
     self.nfofilename = "%s.nfo" % utils.stringtofile(self.title)
     self.jsonfilename = "%s.json" % utils.stringtofile(self.title)
 def __init__(self, urlid, title):
     self.urlid = urlid
     self.title = title
     self.path = utils.uni_join(const.libpath, "%s shows" % const.provider, utils.stringtofile(self.title))
     self.nfofilename = "tvshow.nfo"
 def test_add_show_to_kodi_lib(self):
     """Does show.add_update() cause the show to be added to kodi library?"""
     episodepath = uni_join(const.libpath, "%s shows" % const.provider, "%s\\" % stringtofile(self.show.title))
     libfiles = [show["file"] for show in rpc("VideoLibrary.GetTVShows", properties=["file"])['tvshows']]
     self.assertIn(episodepath, libfiles)
 def test_movie_with_NFO_added_to_kodi_lib(self):
     """Does movie.add_update() cause the movie to be added to kodi library when .nfo created?"""
     libfiles = [movie["file"] for movie in rpc("VideoLibrary.GetMovies", properties=["file"])['movies']]
     self.assertIn(uni_join(self.movie.path, self.movie.htmfilename), libfiles)
 def setUpClass(cls):
     cls.movie = library.Movie(urlid="/program/KOIF47000608/der-untergang", title="Der Untergang")
     library.execute(to_update_add=[cls.movie])
     libfiles = [movie["file"] for movie in rpc("VideoLibrary.GetMovies", properties=["file"])['movies']]
     assert uni_join(cls.movie.path, cls.movie.htmfilename) in libfiles
     library.execute(to_remove=[cls.movie])