I would like to suggest an improvement to the game source management system: it would be very useful to have a function that automatically checks the availability of each source (link or torrent) before allowing the user to start the download. This would help ensure that users don't try to download games from sources that are no longer active or that don't work properly, improving the overall experience and avoiding frustration.
The idea would be that, before the user can start downloading a game, the system checks that the sources associated with the game are working. This could be done by checking the status of each HTTP link or the status of each torrent.
We can use a simple HTTP request to check if the source link is working and in the case of Torrent, we can use a library like libtorrent to check if the torrent is active and if there are peers available for connection
Here is an example code for direct software links that use HTTP;
import requests def verify_link(url): try: response = requests.get(url, timeout=5) # Timeout of 5 seconds to avoid blocks if response.status_code == 200: return True else: return False # The server responded, but with an error (e.g. 404, 500) except requests.RequestException: return False # If a connection error or timeout occursHere is some example code for torrenting;
import libtorrent as lt def verify_torrent(torrent_file): ses = lt.session() info = lt.torrent_info(torrent_file) h = ses.add_torrent({'ti': info, 'save_path': './'}) # Wait a few seconds to see if the torrent connects for _ in range(10): status = h.status() if status.state == lt.torrent_status.seeding: return True # The torrent is active and has peers return FalseThese functions can be integrated into the system so that, when trying to download a game, the user will only see the active sources, as shown in the example below;
sources = [ "http://example.com/jogo1", "http://example.com/jogo2", "path/to/torrent1.torrent" ] for source in sources: if source.endswith(".torrent"): if verify_torrent(source): print(f"Torrent {source} is working.") else: print(f"Torrent {source} is not working.") else: if verify_link(source): print...Please authenticate to join the conversation.
🧐 In consideration
Suggestion
About 1 year ago

arcanjo
Get notified by email when there are changes.
🧐 In consideration
Suggestion
About 1 year ago

arcanjo
Get notified by email when there are changes.