Exemplo n.º 1
0
    def parse_tracks_from_xml(self, tracks_xml):
        """Extracts track information from XmlNode objects and stores that into Metadata objects.

        Args:
            tracks_xml -- list of XmlNode objects
        """
        for node in tracks_xml:
            if "release_list" in node.children and "release" in node.release_list[0].children:
                for rel_node in node.release_list[0].release:
                    track = Metadata()
                    recording_to_metadata(node, track)
                    release_to_metadata(rel_node, track)
                    rg_node = rel_node.release_group[0]
                    release_group_to_metadata(rg_node, track)
                    if "release_event_list" in rel_node.children:
                        # Extract contries list from `release_event_list` element
                        # Don't use `country` element as it contains information of a single release
                        # event and is basically for backward compatibility.
                        country = []
                        for re in rel_node.release_event_list[0].release_event:
                            try:
                                country.append(
                                        re.area[0].iso_3166_1_code_list[0].iso_3166_1_code[0].text)
                            except AttributeError:
                                pass
                        track["country"] = ", ".join(country)
                    self.search_results.append((track, node))
            else:
                # This handles the case when no release is associated with a track
                # i.e. the track is a NAT
                track = Metadata()
                recording_to_metadata(node, track)
                track["album"] = _("Standalone Recording")
                self.search_results.append((track, node))
Exemplo n.º 2
0
 def _parse_recording(self, recording):
     recording_to_metadata(recording, self, self.config)
     if self.config.setting["enable_tagger_script"]:
         script = self.config.setting["tagger_script"]
         parser = ScriptParser()
     else:
         script = parser = None
     self._customize_metadata(recording)
     self.loaded = True
     if self.callback:
         self.callback()
     self.tagger.nats.update(True)
Exemplo n.º 3
0
 def _parse_recording(self, recording):
     recording_to_metadata(recording, self, self.config)
     self._customize_metadata()
     m = self.metadata
     run_track_metadata_processors(self.album, m, None, recording)
     if self.config.setting["enable_tagger_script"]:
         script = self.config.setting["tagger_script"]
         if script:
             parser = ScriptParser()
             try:
                 parser.eval(script, m)
             except:
                 self.log.error(traceback.format_exc())
             m.strip_whitespace()
     self.loaded = True
     if self.callback:
         self.callback()
     self.tagger.nats.update(True)
Exemplo n.º 4
0
 def _parse_recording(self, recording):
     recording_to_metadata(recording, self, self.config)
     self._customize_metadata()
     m = self.metadata
     run_track_metadata_processors(self.album, m, None, recording)
     if self.config.setting["enable_tagger_script"]:
         script = self.config.setting["tagger_script"]
         if script:
             parser = ScriptParser()
             try:
                 parser.eval(script, m)
             except:
                 self.log.error(traceback.format_exc())
             m.strip_whitespace()
     self.loaded = True
     if self.callback:
         self.callback()
     self.tagger.nats.update(True)
Exemplo n.º 5
0
 def parse_tracks_from_xml(self, tracks_xml):
     for node in tracks_xml:
         if "release_list" in node.children and "release" in node.release_list[0].children:
             for rel_node in node.release_list[0].release:
                 track = Metadata()
                 recording_to_metadata(node, track)
                 release_to_metadata(rel_node, track)
                 rg_node = rel_node.release_group[0]
                 release_group_to_metadata(rg_node, track)
                 countries = country_list_from_node(rel_node)
                 if countries:
                     track["country"] = ", ".join(countries)
                 self.search_results.append((track, node))
         else:
             # This handles the case when no release is associated with a track
             # i.e. the track is an NAT
             track = Metadata()
             recording_to_metadata(node, track)
             track["album"] = _("Standalone Recording")
             self.search_results.append((track, node))
Exemplo n.º 6
0
    def _parse_recording(self, recording):
        m = self.metadata
        recording_to_metadata(recording, m, self)
        self._customize_metadata()
        run_track_metadata_processors(self.album, m, None, recording)
        if config.setting["enable_tagger_scripts"]:
            for s_pos, s_name, s_enabled, s_text in config.setting[
                    "list_of_scripts"]:
                if s_enabled and s_text:
                    parser = ScriptParser()
                    try:
                        parser.eval(s_text, m)
                    except:
                        log.error(traceback.format_exc())
                    m.strip_whitespace()

        self.loaded = True
        if self.callback:
            self.callback()
            self.callback = None
        self.tagger.nats.update(True)