kelvingakuo / fycharts

Unofficial Spotify Charts API. Get any and all data for top 200 and viral 50 music on Spotify. 27th Apr 2021 Update - fycharts returns empty dataframes due to CloudFlare protection on spotifycharts.com
https://pypi.org/project/fycharts/
MIT License
53 stars 8 forks source link

Invalid URL 'h' #3

Closed DevNull-00 closed 4 years ago

DevNull-00 commented 4 years ago

I don't know what's wrong, but I keep getting this error when I try posting to the webhook. My code:

from fycharts.SpotifyCharts import SpotifyCharts

api = SpotifyCharts()
api.viral50Weekly(output_file = "viral_50_daily.csv", start = "2020-04-30", end = "2020-05-1", region = ["global"], webhook = 'https://mywebhookssite.com/post/')

Full error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/fycharts/SpotifyCharts.py", line 87, in __post_to_endpoint_from_queue
    postToRestEndpoint(df, url, what_data)
  File "/usr/local/lib/python3.6/dist-packages/fycharts/write_to_outputs.py", line 54, in postToRestEndpoint
    raise(e)
  File "/usr/local/lib/python3.6/dist-packages/fycharts/write_to_outputs.py", line 51, in postToRestEndpoint
    requests.post(url, json = dump)
  File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 313, in prepare
    self.prepare_url(url, params)
  File "/usr/local/lib/python3.6/dist-packages/requests/models.py", line 387, in prepare_url
    raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'h': No schema supplied. Perhaps you meant http://h?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fycharts/SpotifyCharts.py", line 89, in __post_to_endpoint_from_queue
    raise RuntimeError(e)
RuntimeError: Invalid URL 'h': No schema supplied. Perhaps you meant http://h?
kelvingakuo commented 4 years ago
  1. Get a legit webhook from this website: https://webhook.site/ The one included with the example is a placeholder.

  2. Place the endpoint inside a list. I believe I made an update, and forgot to update the example.

webhook = ["https://hh.com/post"]