title: Python path as url, absolute local path, relative local path
body: <pre><code>import requests
  from urllib.request import Request, urlopen
  import urllib.request
  import urllib
  from urllib.error import URLError, HTTPError    
  
  def fix_url(self,filename):
          new_filename = filename
          try:
              r = requests.get(filename, verify=False, timeout=5)
              urllib.version = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0'
              new_filename = "downloaded-"+filename.split("//")[-1].split("/")[-1].split(".")[0]+".mp3"
              urllib.request.urlretrieve(filename, new_filename)
  
  
          except Exception as e:
              new_filename = os.path.abspath(filename)
  
          return new_filename
  </code></pre>
  
  <p>The above method has input a filepath.
  The filepath would be one of the following:</p>
  
  <ul>
  <li>valid Url</li>
  <li>invalid url</li>
  <li>local path to an existing file (relative)</li>
  <li>local path to an existing file (absolute)</li>
  </ul>
  
  <p>Is the following method correct?</p>
  
  <p>How can i improve this method?</p>