Ejemplo n.º 1
0
 def __init__(self, releases, disc, parent=None):
     QtGui.QDialog.__init__(self, parent)
     self.releases = releases
     self.disc = disc
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.ui.release_list.setSortingEnabled(True)
     self.ui.release_list.setHeaderLabels([_(u"Album"), _(u"Artist"), _(u"Date"), _(u"Country"),
         _(u"Labels"), _(u"Catalog #s"), _(u"Barcode")])
     if self.releases:
         for release in self.releases:
             labels, catalog_numbers = label_info_from_node(release.label_info_list[0])
             date = release.date[0].text if "date" in release.children else ""
             country = release.country[0].text if "country" in release.children else ""
             barcode = release.barcode[0].text if "barcode" in release.children else ""
             item = QtGui.QTreeWidgetItem(self.ui.release_list)
             item.setText(0, release.title[0].text)
             item.setText(1, artist_credit_from_node(release.artist_credit[0])[0])
             item.setText(2, date)
             item.setText(3, country)
             item.setText(4, ", ".join(labels))
             item.setText(5, ", ".join(catalog_numbers))
             item.setText(6, barcode)
             item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(release.id))
         self.ui.release_list.setCurrentItem(self.ui.release_list.topLevelItem(0))
         self.ui.ok_button.setEnabled(True)
     for i in range(self.ui.release_list.columnCount() - 1):
         self.ui.release_list.resizeColumnToContents(i)
     # Sort by descending date, then ascending country
     self.ui.release_list.sortByColumn(3, QtCore.Qt.AscendingOrder)
     self.ui.release_list.sortByColumn(2, QtCore.Qt.DescendingOrder)
     self.ui.lookup_button.clicked.connect(self.lookup)
Ejemplo n.º 2
0
 def __init__(self, releases, disc, parent=None):
     QtGui.QDialog.__init__(self, parent)
     self.releases = releases
     self.disc = disc
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.ui.release_list.setHeaderLabels([_(u"Album"), _(u"Artist"),
         _(u"Labels"), _(u"Catalog #s"), _(u"Barcode")])
     if self.releases:
         for release in self.releases:
             labels, catalog_numbers = label_info_from_node(release.label_info_list[0])
             barcode = release.barcode[0].text if "barcode" in release.children else ""
             item = QtGui.QTreeWidgetItem(self.ui.release_list)
             item.setText(0, release.title[0].text)
             item.setText(1, artist_credit_from_node(release.artist_credit[0], self.config)[0])
             item.setText(2, ", ".join(labels))
             item.setText(3, ", ".join(catalog_numbers))
             item.setText(4, barcode)
             item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(release.id))
         self.ui.release_list.setCurrentItem(self.ui.release_list.topLevelItem(0))
         self.ui.ok_button.setEnabled(True)
     self.ui.release_list.resizeColumnToContents(0)
     self.ui.release_list.resizeColumnToContents(1)
     self.ui.release_list.resizeColumnToContents(4)
     self.connect(self.ui.lookup_button, QtCore.SIGNAL("clicked()"), self.lookup)
Ejemplo n.º 3
0
    def _parse_versions(self, document):
        """Parse document and return a list of releases"""
        del self.versions[:]
        data = []

        for node in document.metadata[0].release_list[0].release:
            labels, catnums = label_info_from_node(node.label_info_list[0])
            release = {
                "id":      node.id,
                "date":    node.date[0].text if "date" in node.children else "",
                "country": node.country[0].text if "country" in node.children else "",
                "format":  media_formats_from_node(node.medium_list[0]),
                "labels":  ", ".join(set(labels)),
                "catnums": ", ".join(set(catnums)),
                "tracks":  " + ".join([m.track_list[0].count for m in node.medium_list[0].medium]),
                "barcode":
                    node.barcode[0].text
                    if "barcode" in node.children
                    and node.barcode[0].text != ""
                    else _("[no barcode]"),
                "packaging":
                    node.packaging[0].text
                    if "packaging" in node.children
                    else None,
                "disambiguation":
                    node.disambiguation[0].text
                    if "disambiguation" in node.children
                    else None,
                "_disambiguate_name": list(),
            }
            data.append(release)
        data.sort(key=lambda x: x["date"])
        namekeys = ("date", "country", "labels", "catnums", "tracks", "format")
        extrakeys = ("packaging", "barcode", "disambiguation")

        versions = defaultdict(list)
        for release in data:
            name = " / ".join(filter(None, (release[k] for k in namekeys))).replace("&", "&&")
            if name == release["tracks"]:
                name = "%s / %s" % (_('[no release info]'), name)
            versions[name].append(release)

        #de-duplicate names if possible
        for name, releases in versions.iteritems():
            for a, b in combinations(releases, 2):
                for key in extrakeys:
                    (value1, value2) = (a[key], b[key])
                    if value1 != value2:
                        a['_disambiguate_name'].append(value1)
                        b['_disambiguate_name'].append(value2)
        for name, releases in versions.iteritems():
            for release in releases:
                dis = " / ".join(filter(None, uniqify(release['_disambiguate_name']))).replace("&", "&&")
                disname = name if not dis else name + ' / ' + dis
                self.versions.append({'id': release['id'], 'name': disname})
Ejemplo n.º 4
0
 def _parse_release_group(self, document):
     for node in document.metadata[0].release_list[0].release:
         v = {}
         v["mbid"] = node.id
         v["date"] = node.date[0].text if "date" in node.children else ""
         v["country"] = node.country[0].text if "country" in node.children else ""
         labels, catnums = label_info_from_node(node.label_info_list[0])
         v["labels"] = ", ".join(set(labels))
         v["catnums"] = ", ".join(set(catnums))
         v["tracks"] = " + ".join([m.track_list[0].count for m in node.medium_list[0].medium])
         v["format"] = media_formats_from_node(node.medium_list[0])
         self.other_versions.append(v)
     self.other_versions.sort(key=lambda x: x["date"])
Ejemplo n.º 5
0
    def _parse_versions(self, document):
        del self.versions[:]
        data = []

        for node in document.metadata[0].release_list[0].release:
            labels, catnums = label_info_from_node(node.label_info_list[0])
            data.append({
                "id":      node.id,
                "date":    node.date[0].text if "date" in node.children else "",
                "country": node.country[0].text if "country" in node.children else "",
                "format":  media_formats_from_node(node.medium_list[0]),
                "labels":  ", ".join(set(labels)),
                "catnums": ", ".join(set(catnums)),
                "tracks":  " + ".join([m.track_list[0].count for m in node.medium_list[0].medium]),
            })
        data.sort(key=lambda x: x["date"])
        keys = ("date", "country", "labels", "catnums", "tracks", "format")

        for version in data:
            name = " / ".join(filter(None, (version[k] for k in keys))).replace("&", "&&")
            if name == version["tracks"]:
                name = "%s / %s" % (_('[no release info]'), name)

            self.versions.append({"id": version["id"], "name": name})
Ejemplo n.º 6
0
    def _parse_versions(self, document):
        """Parse document and return a list of releases"""
        del self.versions[:]
        data = []

        namekeys = ("tracks", "year", "country", "format", "label", "catnum")
        headings = {
            "tracks":   N_('Tracks'),
            "year":     N_('Year'),
            "country":  N_('Country'),
            "format":   N_('Format'),
            "label":    N_('Label'),
            "catnum":   N_('Cat No'),
        }
        extrakeys = ("packaging", "barcode", "disambiguation")
        for node in document.metadata[0].release_list[0].release:
            labels, catnums = label_info_from_node(node.label_info_list[0])

            countries = []
            if 'release_event_list' in node.children:
                for release_event in node.release_event_list[0].release_event:
                    if "area" in release_event.children:
                        countries.append(release_event.area[0].iso_3166_1_code_list[0].iso_3166_1_code[0].text)

            formats = []
            for medium in node.medium_list[0].medium:
                if "format" in medium.children:
                    formats.append(medium.format[0].text)
            release = {
                "id":      node.id,
                "year":    node.date[0].text[:4] if "date" in node.children else "????",
                "country": "+".join(countries) if countries
                    else node.country[0].text if "country" in node.children
                    else "??",
                "format":  media_formats_from_node(node.medium_list[0]),
                "label":  ", ".join([' '.join(x.split(' ')[:2]) for x in set(labels)]),
                "catnum": ", ".join(set(catnums)),
                "tracks":  "+".join([m.track_list[0].count for m in node.medium_list[0].medium]),
                "barcode":
                    node.barcode[0].text
                    if "barcode" in node.children
                    and node.barcode[0].text != ""
                    else _("[no barcode]"),
                "packaging":
                    node.packaging[0].text
                    if "packaging" in node.children
                    else None,
                "disambiguation":
                    node.disambiguation[0].text
                    if "disambiguation" in node.children
                    else None,
                "_disambiguate_name": list(),
                "totaltracks": sum([int(m.track_list[0].count) for m in node.medium_list[0].medium]),
                "countries": countries,
                "formats": formats,
            }
            data.append(release)

        versions = defaultdict(list)
        for release in data:
            name = " / ".join([release[k] for k in namekeys]).replace("&", "&&")
            if name == release["tracks"]:
                name = "%s / %s" % (_('[no release info]'), name)
            versions[name].append(release)

        # de-duplicate names if possible
        for name, releases in versions.items():
            for a, b in combinations(releases, 2):
                for key in extrakeys:
                    (value1, value2) = (a[key], b[key])
                    if value1 != value2:
                        a['_disambiguate_name'].append(value1)
                        b['_disambiguate_name'].append(value2)
        for name, releases in versions.items():
            for release in releases:
                dis = " / ".join(filter(None, uniqify(release['_disambiguate_name']))).replace("&", "&&")
                disname = name if not dis else name + ' / ' + dis
                version = {
                    'id': release['id'],
                    'name': disname,
                    'totaltracks': release['totaltracks'],
                    'countries': release['countries'],
                    'formats': release['formats'],
                }
                self.versions.append(version)
        self.version_headings = " / ".join(_(headings[k]) for k in namekeys)