Exemplo n.º 1
0
 def setUp(self):
     library_cache = LibraryCache()
     self.kodi = KodiInterface(library_cache)
     self.kodi.update_cache()
     self.player = CustomPlayer()
     self.player.set_kodi(self.kodi)
     self.kodi.find_and_play({
         'titles': ['Maze Runner'],
     })
Exemplo n.º 2
0
class TestIndexing(unittest.TestCase):
    def setUp(self):
        library_cache = LibraryCache()
        self.kodi = KodiInterface(library_cache)
        self.kodi.update_cache()
        self.movies, self.tvshows = self.kodi._get_video_library()
        # self.library_index = create_library_index(self.movies, self.tvshows)

    def test_indexing(self):
        print('test')
Exemplo n.º 3
0
 def setUp(self):
     library_cache = LibraryCache()
     self.kodi = KodiInterface(library_cache)
     self.kodi.update_cache()
     self.player = CustomPlayer()
     self.player.set_kodi(self.kodi)
Exemplo n.º 4
0
class TestPreviousNext(unittest.TestCase):
    def setUp(self):
        library_cache = LibraryCache()
        self.kodi = KodiInterface(library_cache)
        self.kodi.update_cache()
        self.player = CustomPlayer()
        self.player.set_kodi(self.kodi)

    def test_no_current_item_previous(self):
      current_item = self.player._get_current_item()
      self.assertIsNone(current_item)

      self.assertFalse(self.kodi.previous_item())

      current_item = self.player._get_current_item()
      self.assertIsNone(current_item)

    def test_no_previous_item(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '1',
            'episode': '1',
        })

        self.assertFalse(self.kodi.previous_item())

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 401)
        self.assertEqual(current_item['season'], 1)
        self.assertEqual(current_item['episode'], 1)

    def test_no_next_item(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '6',
            'episode': '24',
        })

        self.assertFalse(self.kodi.next_item())

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 536)
        self.assertEqual(current_item['season'], 6)
        self.assertEqual(current_item['episode'], 24)

    def test_previous_item(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '2',
            'episode': '2',
        })
        self.assertTrue(self.kodi.previous_item())

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 423)
        self.assertEqual(current_item['season'], 2)
        self.assertEqual(current_item['episode'], 1)

    def test_previous_item_cross_season(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '2',
            'episode': '1',
        })
        self.assertTrue(self.kodi.previous_item())

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 422)
        self.assertEqual(current_item['season'], 1)
        self.assertEqual(current_item['episode'], 22)

    def test_next_item(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '1',
            'episode': '1',
        })
        self.assertTrue(self.kodi.next_item())

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 402)
        self.assertEqual(current_item['season'], 1)
        self.assertEqual(current_item['episode'], 2)

    def test_next_item_cross_season(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '1',
            'episode': '22',
        })
        self.assertTrue(self.kodi.next_item())

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 423)
        self.assertEqual(current_item['season'], 2)
        self.assertEqual(current_item['episode'], 1)
Exemplo n.º 5
0
    def stop(self):
        print('Stopping client')
        self.client.stop()

if __name__ == '__main__':
    xbmc.log('Starting Kodi connect tunnel', level=xbmc.LOGNOTICE)
    xbmc.log('Kodi connect pid={}'.format(os.getpid()), level=xbmc.LOGNOTICE)

    try:
        once = OnlyOnce()
    except OnlyOnceException:
        xbmc.log('Kodi connect tunnel already running, exiting', level=xbmc.LOGNOTICE)
        sys.exit(0)

    library_cache = LibraryCache()
    kodi = KodiInterface(library_cache)
    handler = Handler(kodi)

    monitor = CustomMonitor(kodi)
    player = CustomPlayer()
    player.set_kodi(kodi)

    client = Client(KODI_CONNECT_URL, kodi, handler)
    client_thread = ClientThread(client)
    client_thread.start()

    try:
        while not monitor.abortRequested():
            # Sleep/wait for abort for 3 seconds
            if monitor.waitForAbort(3):
                # Abort was requested while waiting. We should exit
class TestSearchAndPlay(unittest.TestCase):
    def setUp(self):
        library_cache = LibraryCache()
        self.kodi = KodiInterface(library_cache)
        self.kodi.update_cache()
        self.player = CustomPlayer()
        self.player.set_kodi(self.kodi)

    def test_search_and_play_not_found(self):
        ret = self.kodi.find_and_play({
            'titles': ['some made up name'],
        })
        current_item = self.player._get_current_item()

        self.assertFalse(ret)
        self.assertIsNone(current_item)

    def test_search_and_play_tvshow(self):
        self.kodi.find_and_play({
            'titles': ['How I Met Your Mother'],
            'season': '2',
            'episode': '1',
        })
        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 423)
        self.assertEqual(current_item['season'], 2)
        self.assertEqual(current_item['episode'], 1)

    def test_search_and_play_tvshow_next_episode(self):
        self.kodi.find_and_play({
            u'genres': [],
            u'episode': None,
            u'roles': [],
            u'season': None,
            u'mediaType': None,
            u'titles': [u'How I Met Your Mother', u'Goodbye How I Met Your Mother', u'How I Met Your Mother: Extras', u'How I Met Your Puppet Mother'],
            u'actors': [],
            u'collections': [],
        })

        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'episode')
        self.assertEqual(current_item['tvshowid'], 21)
        self.assertEqual(current_item['id'], 487)
        self.assertEqual(current_item['season'], 4)
        self.assertEqual(current_item['episode'], 23)

    def test_search_and_play_movie_by_title(self):
        self.kodi.find_and_play({
            'titles': ['Maze Runner'],
        })
        current_item = self.player._get_current_item()

        print(current_item)
        self.assertEqual(current_item['type'], 'movie')
        self.assertEqual(current_item['id'], 161)

    def test_search_and_play_movie_by_actor(self):
        self.kodi.find_and_play({
            'actors': ['Jason Statham'],
        })
        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'movie')
        self.assertIn(current_item['id'], [202, 163, 48])

    def test_search_and_play_movie_by_title_and_actor(self):
        self.kodi.find_and_play({
            'titles': ['Furious'],
            'actors': ['Jason Statham'],
        })
        current_item = self.player._get_current_item()

        self.assertEqual(current_item['type'], 'movie')
        self.assertEqual(current_item['id'], 202)
Exemplo n.º 7
0
class TestPlaybackControl(unittest.TestCase):
    def setUp(self):
        library_cache = LibraryCache()
        self.kodi = KodiInterface(library_cache)
        self.kodi.update_cache()
        self.player = CustomPlayer()
        self.player.set_kodi(self.kodi)
        self.kodi.find_and_play({
            'titles': ['Maze Runner'],
        })
        run_one()

    def test_pause(self):
        self.kodi.pause()

        self.assertEqual(self.player.speed, 0)

    def test_resume(self):
        self.kodi.pause()

        self.assertEqual(self.player.speed, 0)

        self.kodi.resume()

        self.assertEqual(self.player.speed, 1)

    def test_stop(self):
        self.kodi.stop()

        self.assertEqual(self.player.speed, 0)
        self.assertIsNone(self.player.current_item)

        self.kodi.resume()

        self.assertEqual(self.player.speed, 0)
        self.assertIsNone(self.player.current_item)
Exemplo n.º 8
0
 def setUp(self):
     library_cache = LibraryCache()
     self.kodi = KodiInterface(library_cache)
     self.kodi.update_cache()
     self.movies, self.tvshows = self.kodi._get_video_library()