Ejemplo n.º 1
0
class TestMTV(unittest.TestCase):

    def setUp(self):
        self.mtv = MTVItaly('mock_url://', 3)

    def test_list_show(self):
        shows = self.mtv.list_shows()
        self.assertIsNotNone(shows)
        titles = tuple(show[0] for show in shows)
        self.assertIn('Il Testimone', titles)

    def test_list_seasons(self):
        seasons = self.mtv.list_seasons('il-testimone')
        self.assertIsNotNone(seasons)
        titles = tuple(season[0] for season in seasons)
        self.assertIn('Stagione 1', titles)

    def test_list_seasons_empty(self):
        with self.assertRaises(Exception):
            self.mtv.list_seasons('ballerini-dietro-il-sipario')

    def test_list_episodes(self):
        episodes = self.mtv.list_episodes('il-testimone', 's01')
        self.assertIsNotNone(episodes)
        titles = tuple(episode[0] for episode in episodes)
        self.assertIn('Loco, loco, loco', titles)

    
    @mock.patch('mtvit.urllib')
    def test_quality_selection(self, mock_urllib):
        fn = os.path.join(os.path.dirname(__file__), 'mocks', 'video_qualities_mock.xml')
        mock_urllib.urlopen.return_value = fn
        episode_qualities = self.mtv.list_video_qualities('il-testimone', 's01', 'il-testimone-s01e07')
        self.assertIsNotNone(episode_qualities)
        normalized_qualities = self.mtv.normalize_qualities(episode_qualities)
        self.assertEqual(3, len(normalized_qualities))
Ejemplo n.º 2
0
 def setUp(self):
     self.mtv = MTVItaly('mock_url://', 3)
Ejemplo n.º 3
0
import xbmcplugin
import xbmcaddon
import urlparse
import xbmc

base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])

xbmcplugin.setContent(addon_handle, 'movies')
addon = xbmcaddon.Addon()
quality = int(addon.getSetting('quality'))

NO_EPISODES = 30001

mtv = MTVItaly(base_url, quality)

mode = args.get('mode', None)

if mode is None:
    for show in mtv.list_shows():
        li = xbmcgui.ListItem(show[0],
                              iconImage=show[1],
                              thumbnailImage=show[1])
        xbmcplugin.addDirectoryItem(handle=addon_handle,
                                    url=show[2],
                                    listitem=li,
                                    isFolder=True)

    xbmcplugin.endOfDirectory(addon_handle)
Ejemplo n.º 4
0
import xbmcplugin
import xbmcaddon
import urlparse
import xbmc

base_url = sys.argv[0]
addon_handle = int(sys.argv[1])
args = urlparse.parse_qs(sys.argv[2][1:])

xbmcplugin.setContent(addon_handle, 'movies')
addon = xbmcaddon.Addon()
quality = int(addon.getSetting('quality'))

NO_EPISODES = 30001

mtv = MTVItaly(base_url, quality)

mode = args.get('mode', None)

if mode is None:
    for show in mtv.list_shows():
        li = xbmcgui.ListItem(show[0], iconImage = show[1], thumbnailImage = show[1])
        xbmcplugin.addDirectoryItem(handle = addon_handle, url = show[2], listitem = li, isFolder = True)

    xbmcplugin.endOfDirectory(addon_handle)

elif mode[0] == 'list_seasons':
    show_id = args['show_id'][0]
    try:
        for season in mtv.list_seasons(show_id):
            li = xbmcgui.ListItem(season[0])