def getMediaCounts(self, media): amcc = artistDBMediaCountsClass() results = self.bsdata.findAll("ul", {"class": "facets_nav"}) if results is None or len(results) == 0: amcc.err = "No Counts" return amcc for result in results: for li in result.findAll("li"): ref = li.find("a") if ref: attrs = ref.attrs span = ref.find("span", {"class": "facet_count"}) count = None if span: count = span.text credittype = attrs.get("data-credit-type") creditsubtype = attrs.get("data-credit-subtype") if credittype and creditsubtype: if amcc.counts.get(credittype) == None: amcc.counts[credittype] = {} if amcc.counts[credittype].get(creditsubtype) == None: try: amcc.counts[credittype][creditsubtype] = int(count) except: amcc.counts[credittype][creditsubtype] = count amcc.err = "Non Int" return amcc
def getMediaCounts(self, media): amcc = artistDBMediaCountsClass() credittype = "Releases" if amcc.counts.get(credittype) == None: amcc.counts[credittype] = {} for creditsubtype in media.media.keys(): amcc.counts[credittype][creditsubtype] = int( len(media.media[creditsubtype])) return amcc