# Buggy code
def _is_video(self, result):
    # ensure result is not a channel
    not_video = (
        result.find("channel") is not None
        or "yt-lockup-channel" in result.parent.attrs["class"]
        or "yt-lockup-channel" in result.attrs["class"]
    )

    # ensure result is not a mix/playlist
    not_video = not_video or "yt-lockup-playlist" in result.parent.attrs["class"]

    # ensure video result is not an advertisement
    not_video = not_video or result.find("googleads") is not None

    video = not not_video
    return video


# Traceback (AttributeError)
INFO: 2. Downloading "https://open.spotify.com/track/5dPwLIsgL4gklXWAAM1VZY"

Traceback (most recent call last):
File "/usr/local/bin/spotdl", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/spotdl/command_line/__main__.py", line 48, in main
spotdl.match_arguments()
File "/usr/local/lib/python3.7/site-packages/spotdl/command_line/core.py", line 79, in match_arguments
self.arguments["list"],
File "/usr/local/lib/python3.7/site-packages/spotdl/command_line/core.py", line 346, in download_tracks_from_file
metadata = search_metadata.on_youtube_and_spotify()
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata_search.py", line 89, in on_youtube_and_spotify
metadata = caller()
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata_search.py", line 185, in _on_youtube_and_spotify_for_type_spotify
youtube_video = self._best_on_youtube_search_for_type_spotify(search_query)
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata_search.py", line 178, in _best_on_youtube_search_for_type_spotify
video = self._best_on_youtube_search_for_type_query(search_query)
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata_search.py", line 153, in _best_on_youtube_search_for_type_query
videos = self.providers["youtube"].search(query)
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata/providers/youtube.py", line 247, in search
return YouTubeSearch().search(query)
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata/providers/youtube.py", line 119, in search
videos = self._fetch_search_results(html, limit=limit)
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata/providers/youtube.py", line 83, in _fetch_search_results
video = self._extract_video_details_from_result(result)
File "/usr/local/lib/python3.7/site-packages/spotdl/metadata/providers/youtube.py", line 62, in _extract_video_details_from_result
video_time = html.find("span", class_="video-time").get_text()
AttributeError: 'NoneType' object has no attribute 'get_text'

# Fixed code
def _is_video(self, result):
    # ensure result is not a channel
    not_video = (
        result.find("channel") is not None
        or "yt-lockup-channel" in result.parent.attrs["class"]
        or "yt-lockup-channel" in result.attrs["class"]
    )

    # ensure result is not a mix/playlist
    not_video = not_video or "yt-lockup-playlist" in result.parent.attrs["class"]

    # ensure video result is not an advertisement
    not_video = not_video or result.find("googleads") is not None
    # ensure video result is not a live stream
    not_video = not_video or result.find("span", class_="video-time") is None

    video = not not_video
    return video