Uploaded image for project: 'Picard'
  1. Picard
  2. PICARD-850

ZeroDivisionError: integer division or modulo by zero

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Normal Normal
    • None
    • 1.3.2
    • None
    • None
    • ubuntu 16.04
      uname -a:
      Linux manganes 4.4.0-46-generic #67-Ubuntu SMP Thu Oct 20 15:05:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

      On some albums/releases picard stays showing the "[loading album information]" forever.
      One of these albums/releases is this one: http://musicbrainz.org/release/25696ae2-9c2f-4f81-99ec-69e3042c8dfe
      But it also happens with others.
      when I run it from the command line it shows following error:

      Traceback (most recent call last):
      File "/usr/lib/picard/picard/webservice.py", line 289, in _process_reply
      handler(document, reply, error)
      File "/usr/lib/picard/picard/album.py", line 174, in _release_request_finished
      self._finalize_loading(error)
      File "/usr/lib/picard/picard/album.py", line 223, in _finalize_loading
      track = self._finalize_loading_track(track_node, mm, artists, va, absolutetracknumber)
      File "/usr/lib/picard/picard/album.py", line 294, in _finalize_loading_track
      track._customize_metadata()
      File "/usr/lib/picard/picard/track.py", line 124, in _customize_metadata
      self._convert_folksonomy_tags_to_genre()
      File "/usr/lib/picard/picard/track.py", line 142, in _convert_folksonomy_tags_to_genre
      taglist.append((100 * count / maxcount, name))
      ZeroDivisionError: integer division or modulo by zero

      I managed to correct the error (I don't know if this is the right way) by adding following line to /usr/lib/picard/picard/track.py:142

      if maxcount != 0:

      so it looks like this:

      def _convert_folksonomy_tags_to_genre(self):

      1. Combine release and track tags
        tags = dict(self.folksonomy_tags)
        self.merge_folksonomy_tags(tags, self.album.folksonomy_tags)
        if self.album.release_group:
        self.merge_folksonomy_tags(tags, self.album.release_group.folksonomy_tags)
        if not tags:
        return
      2. Convert counts to values from 0 to 100
        maxcount = max(tags.values())
        taglist = []
        for name, count in tags.items():
        if maxcount != 0:
        taglist.append((100 * count / maxcount, name))
        taglist.sort(reverse=True)
      3. And generate the genre metadata tag
        maxtags = config.setting['max_tags']
        minusage = config.setting['min_tag_usage']
        ignore_tags = config.setting['ignore_tags']
        genre = []
        for usage, name in taglist[:maxtags]:
        if name in ignore_tags:
        continue
        if usage < minusage:
        break
        name = _TRANSLATE_TAGS.get(name, name.title())
        genre.append(name)
        join_tags = config.setting['join_tags']
        if join_tags:
        genre = [join_tags.join(genre)]
        self.metadata['genre'] = genre

      should I make a github fork + pull request?

            Unassigned Unassigned
            falkartis Falk Bay
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package