MCPcopy Create free account
hub / github.com/dbr/tvdb_api / _setItem

Method _setItem

tvdb_api.py:874–895  ·  view source on GitHub ↗

Creates a new episode, creating Show(), Season() and Episode()s as required. Called by _getShowData to populate show Since the nice-to-use tvdb[1][24]['name] interface makes it impossible to do tvdb[1][24]['name] = "name" and still be capable of checking if an episod

(self, sid, seas, ep, attrib, value)

Source from the content-addressed store, hash-verified

872 return src
873
874 def _setItem(self, sid, seas, ep, attrib, value):
875 """Creates a new episode, creating Show(), Season() and
876 Episode()s as required. Called by _getShowData to populate show
877
878 Since the nice-to-use tvdb[1][24]['name] interface
879 makes it impossible to do tvdb[1][24]['name] = "name"
880 and still be capable of checking if an episode exists
881 so we can raise tvdb_shownotfound, we have a slightly
882 less pretty method of setting items.. but since the API
883 is supposed to be read-only, this is the best way to
884 do it!
885 The problem is that calling tvdb[1][24]['episodename'] = "name"
886 calls __getitem__ on tvdb[1], there is no way to check if
887 tvdb.__dict__ should have a key "1" before we auto-create it
888 """
889 if sid not in self.shows:
890 self.shows[sid] = Show()
891 if seas not in self.shows[sid]:
892 self.shows[sid][seas] = Season(show=self.shows[sid])
893 if ep not in self.shows[sid][seas]:
894 self.shows[sid][seas][ep] = Episode(season=self.shows[sid][seas])
895 self.shows[sid][seas][ep][attrib] = value
896
897 def _setShowData(self, sid, key, value):
898 """Sets self.shows[sid] to a new Show instance, or sets the data

Callers 1

_getShowDataMethod · 0.95

Calls 3

ShowClass · 0.85
SeasonClass · 0.85
EpisodeClass · 0.85

Tested by

no test coverage detected