示例#1
0
    def get_artist_id(self, artist_url):
        # We go to artist page to pick data we need to make the ARTIST_INFO key.

        artist_id = None
        if artist_url in KEY_INFO.keys():
            # print("\n\n\n\nA:\n\n\n\n")
            key = KEY_INFO[artist_url]
            if key in ARTIST_INFO.keys():
                artist_id = ARTIST_INFO[key]
                return artist_id

        # Key maker here, writes the artist data in the db. Makes it much simpler. Nah?
        key = self.key_maker(artist_url)
        if key is not None and artist_url is not None:
            if key in ARTIST_INFO.keys():
                artist_id = ARTIST_INFO.get(key)
                return artist_id
                # print(artist_id)
            else:
                print("FATAL ERROR :: Artist_id not found.")
        else:
            # If it ever comes to here, the page will not have an Artist
            print("FATAL ERROR :: Artist_id not found. Artist_url broken")
        # Let's return None here, and not pick rest of the data if the artist_id is not found.
        # Artist id is used in artworks table only.
        return artist_id
示例#2
0
    def get_artist_id(self, artist_url):
        # We go to artist page to pick data we need to make the ARTIST_INFO key.

        artist_id = None
        if artist_url in KEY_INFO.keys():
            key = KEY_INFO.get(artist_url)
            if key in ARTIST_INFO.keys():
                artist_id = ARTIST_INFO.get(key)
            return artist_id
        else:
            # self.artist_id_slave (key_maker) returns the artist_id
            artist_id = self.artist_id_slave(artist_url)
            return artist_id
示例#3
0
    def artist_id_slave(self, artist_url):
        visited.discard(artist_url)
        soup = TheMiner.fetch_page(artist_url)
        if soup is not None:
            self.get_artist_data(soup, artist_url)
            # Getting the key from KEY_INFO
            if artist_url in KEY_INFO.keys():
                key = KEY_INFO.get(artist_url)
                # Getting artist_id using the key from ARTIST_INFO
                if key in ARTIST_INFO.keys():
                    artist_id = ARTIST_INFO.get(key)
                    return artist_id
                else:
                    print("ARTIST_ID_SLAVE : Artist id not in ARTIST_INFO")
                    return None
            else:
                print("ARTIST_ID_SLAVE : Could not find artist_id")
                return None

        else:
            print("ARTIST_ID_SLAVE : Soup not returned")
            return None
示例#4
0
    def get_artist_id(self, artist_url):
        # We go to artist page to pick data we need to make the ARTIST_INFO key.
        # print(f"\n\n\n\nARTIST_ID_GET:\n{artist_url}\n{KEY_INFO}\n\n\n\n")

        artist_id = None
        if artist_url in KEY_INFO.keys():
            # print("\n\n\n\nA:\n\n\n\n")
            key = KEY_INFO[artist_url]
            artist_id = ARTIST_INFO[key]
        else:
            key = self.key_maker(artist_url)
            if key is not None and artist_url is not None:
                if key in ARTIST_INFO.keys():
                    artist_id = ARTIST_INFO.get(key)
                    # print(artist_id)
                else:
                    print("FATAL ERROR :: Artist_id not found.")
            else:
                # If it ever comes to here, the page will not have an Artist
                print("FATAL ERROR :: Artist_id not found. Artist_url broken")
            # Let's return None here, and not pick rest of the data if the artist_id is not found.
            # Artist id is used in artworks table only.
        return artist_id