def load_artist_songs_with_filters(
        self,
        artist_name: str,
        most_popular: bool = True,
        max_songs: Optional[int] = None,
        max_pages: int = 50,
    ) -> Document:
        """
        Load the most or least popular song of an artist.

        Args:
            artist_name (str): The artist's name.
            most_popular (bool): True for most popular, False for least popular song.
            max_songs (Optional[int]): Maximum number of songs to consider for popularity.
            max_pages (int): Maximum number of pages to fetch.

        Returns:
            Document: A document containing lyrics of the most/least popular song.

        """
        artist = self.genius.search_artist(artist_name, max_songs=1)
        if not artist:
            return None

        songs_fetched = 0
        page = 1
        songs = []
        while (
            page
            and page <= max_pages
            and (max_songs is None or songs_fetched < max_songs)
        ):
            request = self.genius.artist_songs(
                artist.id, sort="popularity", per_page=50, page=page
            )
            songs.extend(request["songs"])
            songs_fetched += len(request["songs"])
            page = (
                request["next_page"]
                if (max_songs is None or songs_fetched < max_songs)
                else None
            )

        target_song = songs[0] if most_popular else songs[-1]
        song_details = self.genius.search_song(target_song["title"], artist.name)
        return Document(text=song_details.lyrics) if song_details else None

        Load the most or least popular song of an artist.

        Args:
            artist_name (str): The artist's name.
            most_popular (bool): True for most popular, False for least popular song.
            max_songs (Optional[int]): Maximum number of songs to consider for popularity.
            max_pages (int): Maximum number of pages to fetch.

        Returns:
            Document: A document containing lyrics of the most/least popular song.

        
llama-index-integrations/readers/llama-index-readers-genius/llama_index/readers/genius/base.py