webscout 3.9__py3-none-any.whl → 4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webscout might be problematic. Click here for more details.
- webscout/Extra/__init__.py +3 -1
- webscout/Extra/weather.py +49 -0
- webscout/Extra/weather_ascii.py +18 -0
- webscout/Local/_version.py +1 -1
- webscout/YTdownloader.py +1105 -0
- webscout/__init__.py +3 -1
- webscout/cli.py +116 -221
- webscout/version.py +2 -2
- webscout/webai.py +0 -4
- {webscout-3.9.dist-info → webscout-4.0.dist-info}/METADATA +42 -3
- {webscout-3.9.dist-info → webscout-4.0.dist-info}/RECORD +15 -12
- {webscout-3.9.dist-info → webscout-4.0.dist-info}/LICENSE.md +0 -0
- {webscout-3.9.dist-info → webscout-4.0.dist-info}/WHEEL +0 -0
- {webscout-3.9.dist-info → webscout-4.0.dist-info}/entry_points.txt +0 -0
- {webscout-3.9.dist-info → webscout-4.0.dist-info}/top_level.txt +0 -0
webscout/Extra/__init__.py
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
def get(location):
|
|
4
|
+
"""Fetches weather data for the given location.
|
|
5
|
+
|
|
6
|
+
Args:
|
|
7
|
+
location (str): The location for which to fetch weather data.
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
dict: A dictionary containing weather data if the request is successful,
|
|
11
|
+
otherwise a string indicating the error.
|
|
12
|
+
"""
|
|
13
|
+
url = f"https://wttr.in/{location}?format=j1"
|
|
14
|
+
|
|
15
|
+
response = requests.get(url)
|
|
16
|
+
|
|
17
|
+
if response.status_code == 200:
|
|
18
|
+
return response.json()
|
|
19
|
+
else:
|
|
20
|
+
return f"Error: Unable to fetch weather data. Status code: {response.status_code}"
|
|
21
|
+
|
|
22
|
+
def print_weather(weather_data):
|
|
23
|
+
"""Prints the weather data in a user-friendly format.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
weather_data (dict or str): The weather data returned from get_weather()
|
|
27
|
+
or an error message.
|
|
28
|
+
"""
|
|
29
|
+
if isinstance(weather_data, str):
|
|
30
|
+
print(weather_data)
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
current = weather_data['current_condition'][0]
|
|
34
|
+
location_name = weather_data['nearest_area'][0]['areaName'][0]['value']
|
|
35
|
+
|
|
36
|
+
print(f"Weather in {location_name}:")
|
|
37
|
+
print(f"Temperature: {current['temp_C']}°C / {current['temp_F']}°F")
|
|
38
|
+
print(f"Condition: {current['weatherDesc'][0]['value']}")
|
|
39
|
+
print(f"Humidity: {current['humidity']}%")
|
|
40
|
+
print(f"Wind: {current['windspeedKmph']} km/h, {current['winddir16Point']}")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
print("\nForecast:")
|
|
44
|
+
for day in weather_data['weather']:
|
|
45
|
+
date = day['date']
|
|
46
|
+
max_temp = day['maxtempC']
|
|
47
|
+
min_temp = day['mintempC']
|
|
48
|
+
desc = day['hourly'][4]['weatherDesc'][0]['value']
|
|
49
|
+
print(f"{date}: {min_temp}°C to {max_temp}°C, {desc}")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
def get(location):
|
|
4
|
+
"""Fetches ASCII art weather data for the given location.
|
|
5
|
+
Args:
|
|
6
|
+
location (str): The location for which to fetch weather data.
|
|
7
|
+
|
|
8
|
+
Returns:
|
|
9
|
+
str: ASCII art weather report if the request is successful,
|
|
10
|
+
otherwise an error message.
|
|
11
|
+
"""
|
|
12
|
+
url = f"https://wttr.in/{location}"
|
|
13
|
+
response = requests.get(url, headers={'User-Agent': 'curl'})
|
|
14
|
+
|
|
15
|
+
if response.status_code == 200:
|
|
16
|
+
return "\n".join(response.text.splitlines()[:-1])
|
|
17
|
+
else:
|
|
18
|
+
return f"Error: Unable to fetch weather data. Status code: {response.status_code}"
|
webscout/Local/_version.py
CHANGED