# Buggy code
def scrape(self, bestmatch=True, tries_remaining=5):
    """Search and scrape YouTube to return a list of matching videos."""

    # prevents an infinite loop but allows for a few retries
    if tries_remaining == 0:
        log.debug("No tries left. I quit.")
        return

    search_url = generate_search_url(self.search_query)
    log.debug("Opening URL: {0}".format(search_url))

    item = urllib.request.urlopen(search_url).read()
    items_parse = BeautifulSoup(item, "html.parser")

    videos = []
    for x in items_parse.find_all(
        "div", {"class": "yt-lockup-dismissable yt-uix-tile"}
    ):
        if not is_video(x):
            continue

        y = x.find("div", class_="yt-lockup-content")
        link = y.find("a")["href"][-11:]
        title = y.find("a")["title"]

        try:
            videotime = x.find("span", class_="video-time").get_text()
        except AttributeError:
            log.debug("Could not find video duration on YouTube, retrying..")
            return self.scrape(
                self.raw_song, self.meta_tags, tries_remaining=tries_remaining - 1
            )

        youtubedetails = {
            "link": link,
            "title": title,
            "videotime": videotime,
            "seconds": internals.get_sec(videotime),
        }
        videos.append(youtubedetails)

    if bestmatch:
        return self._best_match(videos)

    return videos


# Traceback (AttributeError)
Traceback (most recent call last):
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 187, in scrape
videotime = x.find('span', class_="video-time").get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 212, in <module>
main()
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 192, in main
download_single(raw_song=const.args.song)
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 118, in download_single
content = youtube_tools.go_pafy(raw_song, meta_tags)
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 32, in go_pafy
track_url = generate_youtube_url(raw_song, meta_tags)
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 103, in generate_youtube_url
url = url_fetch.scrape()
File "C:\Users\User\spotify-downloader-master\core\youtube_tools.py", line 192, in scrape
tries_remaining=tries_remaining-1)
TypeError: scrape() got multiple values for argument 'tries_remaining'

# Fixed code
def scrape(self, bestmatch=True, tries_remaining=5):
    """Search and scrape YouTube to return a list of matching videos."""

    # prevents an infinite loop but allows for a few retries
    if tries_remaining == 0:
        log.debug("No tries left. I quit.")
        return

    search_url = generate_search_url(self.search_query)
    log.debug("Opening URL: {0}".format(search_url))

    item = urllib.request.urlopen(search_url).read()
    items_parse = BeautifulSoup(item, "html.parser")

    videos = []
    for x in items_parse.find_all(
        "div", {"class": "yt-lockup-dismissable yt-uix-tile"}
    ):
        if not is_video(x):
            continue

        y = x.find("div", class_="yt-lockup-content")
        link = y.find("a")["href"][-11:]
        title = y.find("a")["title"]

        try:
            videotime = x.find("span", class_="video-time").get_text()
        except AttributeError:
            log.debug("Could not find video duration on YouTube, retrying..")
            return self.scrape(bestmatch=bestmatch, tries_remaining=tries_remaining - 1)

        youtubedetails = {
            "link": link,
            "title": title,
            "videotime": videotime,
            "seconds": internals.get_sec(videotime),
        }
        videos.append(youtubedetails)

    if bestmatch:
        return self._best_match(videos)

    return videos