Exemple #1
0
    def __CreateReleaseList__(self, results):
        for rel in results:
            cur_release = Release()

            if rel["name"]:
                cur_release.Name = rel["name"]

            if rel["catalogNumber"]:
                cur_release.Catid = rel["catalogNumber"]

            if rel["label"]["name"]:
                cur_release.LabelName = rel["label"]["name"]

            if rel["id"]:
                cur_release.InfoPageLink = rel["id"]

            self.__ReleaseList.append(cur_release)
Exemple #2
0
    def __CreateReleaseList__(self, stream):
        found_item = False
        found_artist = False
        found_title = False
        found_label = False
        found_catnum = False

        cur_artist = ""
        cur_title = ""
        cur_label = ""
        cur_catnum = ""

        for item in stream:
            # check for item found
            if ("name" in item) and (item["name"] == "div"):
                for attTupel in item["data"]:
                    if ("class" in attTupel) and ("item" in attTupel):
                        found_item = True

                        # create a new release object
                        cur_release = Release()
                        

            # check if artist field ends
            if found_artist == True:
                if ("name" in item) and (item["name"] == "h4") and (item["type"] == "EndTag"):
                    found_artist = False

            # check if artist field ends
            if found_label == True:
                if ("name" in item) and (item["name"] == "span") and (item["type"] == "EndTag"):
                    found_label = False
                    cur_release.LabelName = cur_label.strip()

            # check if title field ends
            if found_title == True:
                if ("name" in item) and (item["name"] == "p") and (item["type"] == "EndTag"):
                    found_title = False

                    # add name to Release instance
                    cur_release.Name = cur_artist.strip() + " " + cur_title.strip()

            # check if catnum field ends
            if found_catnum == True:
                if ("name" in item) and (item["name"] == "span") and (item["type"] == "EndTag"):
                    found_catnum = False
                    
                    # add catnum to release
                    cur_release.Catid = cur_catnum.strip()

                    # because here is the item end, reset all data, and
                    # append the current release to the __ReleaseList
                    self.__ReleaseList.append(cur_release)
                    cur_artist =  ""
                    cur_title =  ""
                    cur_label = ""
                    cur_catnum = ""
                    found_item = False

            # check if label found
            if found_item == True:
                if ("name" in item) and (item["name"] == "span"):
                    for attTupel in item["data"]:
                        if ("class" in attTupel) and ("label" in attTupel):
                            found_label = True

            # check if artist found
            if found_item == True:
                if ("name" in item) and (item["name"] == "h4"):
                    for attTupel in item["data"]:
                        if ("class" in attTupel) and ("artist" in attTupel):
                            found_artist = True

            # check if title found
            if found_item == True:
                if ("name" in item) and (item["name"] == "p"):
                    for attTupel in item["data"]:
                        if ("class" in attTupel) and ("title" in attTupel):
                            found_title = True

            # find the infoPageLink
            if found_item == True and found_title:
                if ("name" in item) and (item["name"] == "a"):
                    for attTupel in item["data"]:
                        if attTupel[0] == "href":
                            cur_release.InfoPageLink = attTupel[1]

            # check if catnum found
            if found_item == True:
                if ("name" in item) and (item["name"] == "span"):
                    for attTupel in item["data"]:
                        if ("class" in attTupel) and ("catnum" in attTupel):
                            found_catnum = True

            # fetch artists
            if found_artist == True:
                if item["type"] == "SpaceCharacters":
                    cur_artist += " "
                if item["type"] == "Characters":
                    cur_artist += item["data"]

            # fetch artists
            if found_label == True:
                if item["type"] == "SpaceCharacters":
                    cur_label += " "
                if item["type"] == "Characters":
                    cur_label += item["data"]

            # fetch title
            if found_title == True:
                if item["type"] == "SpaceCharacters":
                    cur_title += " "
                if item["type"] == "Characters":
                    cur_title += item["data"]

            # fetch catnum
            if found_catnum == True:
                if item["type"] == "SpaceCharacters":
                    cur_catnum += " "
                if item["type"] == "Characters":
                    cur_catnum += item["data"]