Arthals

Arthals

bilibili
github

Looking back at that summer, the first "application" I created while playing.

Introduction#

This article is a copy of my Github homepage, and it can be considered as my first fully functional and usable application. Therefore, I decided to use it to fill my first "Programming Application" category.

The inspiration for creating this application can be found in the functional description below. Looking back now, I can still see the inexplicable enthusiasm I had when I was working on this application day and night at the end of August, spending every hour except for eating and sleeping.

My endless enthusiasm for the technology of this application and my interest in playing with various tools probably started in 19 years, which connected the end of the cold winter, the chirping summer, and the beginning of the deep autumn during the long holiday.

I hope I can always maintain this precious "playfulness".

header

Author#

Author's homepage: zhuozhiyongde(Arthals)

Project address: Alfred_HeWeather_Workflow

Source code author's homepage: skefy(Leon)

Source code project address: alfred_workflow_weather

Functional Description#

Query disaster warnings, air quality index (AQI), real-time weather, and weather forecast for the next three days.
This Alfred Workflow uses the HeWeather API (https://dev.heweather.com/), and is only for educational and reference purposes. It cannot be used for commercial purposes.

The source code of this Alfred Workflow is from @skefy(Leon)/alfred_workflow_weather.

Because the original author initially set the base_url to the commercial version API, personal use requires modifying the source code, which is inconvenient. Moreover, the HeWeather API has been updated to v7, but the original author has not synchronized the update. Therefore, based on the source code, I have refactored more than 90% of the original project.

In addition to the above changes, I have also made the following modifications:

  • Added disaster warning query. When there are multiple disaster warnings, it automatically returns a merged and deduplicated string.

  • Added AQI query.

  • Modified the layout of the entries and added more information to each entry, such as sunrise and sunset, precipitation, and perceived temperature. I also introduced Unicode icons in the layout, following the layout of @jason0x43/alfred-weather, making it more concise and intuitive.

  • Added adm and location parameters to the environment variables to accurately locate the city and obtain the city ID. This is also because the original automatic positioning interface is outdated and cannot accurately locate to the county level. Therefore, the automatic positioning function has been abandoned.

  • You can still use the format keyword + space + other city name to get the weather conditions of other cities. If the queried city is not within China, it will not return disaster warnings and AQI information.

  • Considering that most people use the personal/developer version of the API, I changed api in the base_url to devapi.

  • Added error prompts based on the latest version of the v7 API's status code.

  • Changed the original icons to the new version of HeWeather icons, which are more beautiful.

    Regarding this, you can download other versions of HeWeather icons designed by @heweather/WeatherIcon and replace the icons in the ./res/icon-heweather folder by yourself.

  • Added the quicklookurl parameter to the returned results. For each result, you can press or +Y to preview the adaptive webpage returned by the fxLink of the API to obtain more detailed information.

  • Added the date_valid() function to compare the three-day forecast obtained from the interface with the current date. The reason is that when I was writing the code until 5 o'clock, I accidentally discovered that the interface had not updated the data, resulting in the information for the 10th to 12th being returned at 5 o'clock on the 11th. The original author did not correct this, and it will automatically display the information for the 11th to 13th starting from today.

Default keyword: rt#

Required parameters:#

  • api_key: Your WEB API key. Ordinary users have 1000 free requests per day, and developer versions have 16700 free requests. If you have more requirements, please purchase the commercial version or high-performance version API and replace devapi with api in line 65 of main.py according to your needs.

    The developer version of the API can obtain hourly forecasts for the next 24 hours, but I have not been certified yet, so the development of this part is temporarily suspended.

  • adm: The upper-level province or city range of the selected district or county, used to prevent duplicate city names, such as Beijing Chaoyang District and Liaoning Chaoyang City.

  • location: Please select the specific district or county level planning, such as Haidian District/Hanyang County.

Instructions#

  1. Make sure you have the Powerpack feature of Alfred.

  2. Install this workflow.

  3. Register on HeWeather and apply for an API key.

  4. Registration process:

    a. Go to HeWeather to register an account.

    b. After registration, go to Console → Application Management → Create Application → Free Development Version → Fill in an application name → Select Key Type as WEB API → Follow the prompts to complete the registration.

    c. You can find your API Key in the Console-Application Management.

  5. Set the api_key environment parameter.

    It is recommended to copy it somewhere first and check if there are any tabs or line breaks copied along with it. Otherwise, an error may occur.

  6. Set the adm and location environment parameters, which can be entered in Chinese.

Step-1.png

Step-2.png

Preview#

Arthals-HeWeather.png

Arthals-HeWeather2.png


Detailed explanation:

Arthals-HeWeather-explain.png

License#

This project is open source under the GNU General Public License v3.0.

City query, air query, real-time weather, and forecast weather APIs are all from HeWeather®.

HeWeather® is a registered trademark of HeWeather Company.

Weather icons are from @heweather/WeatherIcon by HeWeather.

Warning icons are from Freepik from www.flaticon.com

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.