Exemplo n.º 1
0
    def __getitem__(self, item):
        if not item in self.seasons:
            self._populate_data()

        try:
            return self.seasons[item]
        except KeyError:
            raise error.TVDBIndexError("Season {0} not found".format(item))
Exemplo n.º 2
0
    def __getitem__(self, item):
        if not isinstance(item, int):
            raise error.TVDBValueError(u"Index should be an integer")

        try:
            return self._result[item]
        except (IndexError, TypeError):
            raise error.TVDBIndexError(
                u"Index out of range ({0})".format(item))
Exemplo n.º 3
0
    def __getitem__(self, item):
        if isinstance(item, int):
            try:
                return self.episodes[item]
            except KeyError:
                raise error.TVDBIndexError(
                    u"Episode {0} not found".format(item))

        elif isinstance(item, slice):
            indices = sorted(self.episodes.keys())[item]  # Slice the keys
            return [self[i] for i in indices]
        else:
            raise error.TVDBValueError(u"Index should be an integer")
Exemplo n.º 4
0
    def __getitem__(self, item):
        if len(self.seasons) == 0:
            self._populate_data()

        if isinstance(item, int):
            try:
                return self.seasons[item]
            except KeyError:
                raise error.TVDBIndexError(
                    u"Season {0} not found".format(item))

        elif isinstance(item, slice):
            indices = sorted(self.seasons.keys())[item]  # Slice the keys
            return [self[i] for i in indices]
        else:
            raise error.TVDBValueError(u"Index should be an integer or slice")
Exemplo n.º 5
0
 def __getitem__(self, item):
     try:
         return self.result[item]
     except (IndexError, TypeError):
         raise error.TVDBIndexError("Index out of range ({0})".format(item))
Exemplo n.º 6
0
 def __getitem__(self, item):
     try:
         return self.episodes[item]
     except KeyError:
         raise error.TVDBIndexError("Index {0} not found".format(item))