Skip to content

Suzhou65/Status4HaH

Repository files navigation

Status4HaH

python python version UA Size

Status check for Hentai@Home Client.

Contents

Usage

You need to have E-Hentai account, and already running Hentai@Home client.

Scheduling and server loading

  • Scheduling
    Using Crontab for job scheduling.
#MIM HOUR DAY MONTH WEEK
*/30  *    *    *    *    root  python /script_path/status_notification.py
- Avoiding for making heavy server load on E-Hentai.
- Not recommended for change less then 30 minutes.

E-Hentai account

Using cookies to login is the same as using a browser extension or viewer.

If your browser is Chrome-based (ex. Google Chrome or Microsoft Edge), right-click to open Developer Tools and switch to the Network panel. After refreshing the Hentai@Home page, click the element called hentaiathome.php, which tags cookies. You can find ipb_member_id and ipb_pass_hash.

Please fill in the cookie's value inin theonfiguration file. If you didn't fill in the configuration, it will ask for the cookie when you run the script.

Configuration not found, please initialize.

Please enter the ipb_member_id: 114514
Please enter the ipb_pass_hash: ••••••••••••••••••••••••••••••••

Email alert

  • Google account needed, sign in using App passwords.
  • Receiver mail address is unlimited.

The first time you run the mail alert function, it will check the configuration file. If the mail configuration is not found, it will return a string Mail configuration not found, please initialize.

Telegram alert

  • Using Telegram Bot, contect BotFather create new Bot accounts.
  • HTTP API Token and chat id are needed.
  • If the chat channel wasn't created, the Telegram API will return HTTP 400 Bad Request. You need to start the chat channel, including that bot.

The first time you run the Telegram alert function, it will check the configuration file. If Telegram Bot configuration is not found, it will return the string Telegram configuration not found, please initialize.

Configuration file

  • Status4HaH store configuration as JSON format file.
  • Configuration file named status4hah.config.json.

You can editing the clean copy, which looks like this:

{
  "last_update_time": "",
  "ipb_member_id": "",
  "ipb_pass_hash": "",
  "request_header": "",
  "mail_sender": "",
  "mail_scepter": "",
  "mail_receiver": "",
  "telegram_token": "",
  "telegram_id": "",
  "alert_counting":false
}

If you fill in the correct configuration, it will skip the initialization check and running script.

Modules instantiation

Some module not included in Python Standard Library are needed.

Security and Disclaimer

- Although the password inside the cookie has been hashed,
- if someone modifies the script, add a backdoor function to send it back.
- It's possible to login to your account without knowing the actual username and password.
- The original Status4HaH won't have those functions.
- Please make sure you download the clean copy from this repository.

Import module

  • Import as module
import status4hentai
  • Alternatively, you can import the function independently.
from status4hentai import CheckHentaiatHome

Function

Get HentaiAtHome status

# Get Hentai@Home Status
HentaiAtHomePayload = status4hentai.CheckHentaiatHome(ConfigFilePath)
# Check Hentai@Home status
StatusTable = status4hentai.GetHentaiStatus(HentaiAtHomePayload)
  • It will return Pandas DataFrame if parsing HTML content correctly.
  • If the return is String, it may contain an error message such as an HTTP status code, a cookie expiration alert, or another erroe message. Please review the error handling in status4hah.error.log.

Offline notification

  • The demonstration script isstatus_notification.py.
  • Configuration as follows are needed.
# Configuration file path
ConfigFilePath = "status4hah.config.json"
# Runtime file and path
StatusFilePath = "status4hah.status.csv"
# Status file filter
CheckingResultFilter = ["ID","Created","Client IP","Port","Version","Max Speed","Country"]
# Status file and path
CheckingResultPath = "status4hah.check.csv"
# Alert mode selection
AlertMode = 0
# Alert output filter
AlertFilter = ["Files Served","Trust","Quality","Hitrate","Hathrate"]

When login cookie expires, you will receive an alert message: Cookie expires. Please update the configuration file.

Status recorder

  • The demonstration script isstatus_recorder.py.
  • Configuration as follows are needed.
# Configuration file path
ConfigFilePath = "status4hah.config.json"
# Runtime file and path
StatusFilePath = "status4hah.status.csv"
# Recording file filter
RecordingFilter = ["ID","Created","Client IP","Port","Version","Max Speed","Country"]
# Recording file path
RecordingPath = "status4hah.record.csv"

Web Based Monitor

status_monitor.php is a simple php script webpage to view the status file generated by status_notification.py.

Dependencies

Python version

  • Python 3.6 or above

Python module

  • sys
  • time
  • json
  • pandas
  • logging
  • smtplib
  • requests
  • datetime
  • getpass
  • BeautifulSoup
  • MIMEText

Webpage

  • Apache or NGINX
  • php 7.3 or above, recommend using php-FPM

License

General Public License -3.0

Resources

Beautiful Soup

E-Hentai

Install HentaiatHome

Stack Overflow

Screenshot