[Solved] Python SyntaxError: ‘return’ outside function [closed]


The code of the entire function has to be indented:

def _download_track(self, song_url, track_name, dir_name,metadata):
    if '.mp4' in song_url:
        track_name = track_name + '.m4a'
    else:
        track_name = track_name + '.mp3'        
    file_path = dir_name.replace(".","_") + "https://stackoverflow.com/" + track_name
    print(('Downloading to', file_path))
    if os.path.isfile(file_path):
        return
        #print metadata
        #response = self._get_url_contents(song_url)
        #with open(file_path,'wb') as f:
        #f.write(response.content)
    r = requests.get(song_url, stream=True, verify=False)
    with open(file_path, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024): 
            if chunk:
                f.write(chunk)
                f.flush()
        if '.m4a' in track_name:
            self._update_metadata_mp4(file_path,metadata)
        else :
            self._update_metadata_mp3(file_path,metadata)

solved Python SyntaxError: ‘return’ outside function [closed]