File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import logging
88import os
99import shutil
10+ from library .app import getCurrentVersion
11+ import git
1012
1113def initializeFolders ():
1214 folders = [MOUNT_PATH ]
@@ -67,6 +69,14 @@ def bootUp():
6769 logging .info ("Mount path: %s" , MOUNT_PATH )
6870 logging .info ("TorBox API Key: %s" , TORBOX_API_KEY )
6971 logging .info ("Mount refresh time: %s %s" , MOUNT_REFRESH_TIME , "hours" )
72+
73+ # check version
74+ latest_version = getLatestVersion ()
75+ current_version = getCurrentVersion ()
76+
77+ if latest_version != current_version :
78+ logging .warning (f"!!! A new version of TorBox Media Center is available: { latest_version } . You are running version: { current_version } . Please consider updating to the latest version. !!!" )
79+
7080 initializeFolders ()
7181
7282 return True
@@ -79,3 +89,18 @@ def getMountPath():
7989
8090def getMountRefreshTime ():
8191 return MOUNT_REFRESH_TIME
92+
93+ def getLatestVersion ():
94+ try :
95+ url = "https://github.com/torbox-app/torbox-media-center.git"
96+ g = git .cmd .Git ()
97+ tags_output = g .ls_remote ("--tags" , url )
98+ tags = [line .split ("refs/tags/" )[1 ] for line in tags_output .splitlines () if "refs/tags/" in line ]
99+ tags = [tag for tag in tags if not tag .endswith ("^{}" )]
100+ tags .sort (key = lambda s : list (map (int , s .lstrip ('v' ).split ('.' ))))
101+ latest_tag = tags [- 1 ] if tags else None
102+ return latest_tag
103+ except Exception as e :
104+ logging .error (f"Error fetching latest version: { e } " )
105+ return None
106+
Original file line number Diff line number Diff line change @@ -35,3 +35,6 @@ class MountRefreshTimes(Enum):
3535 MOUNT_REFRESH_TIME = MountRefreshTimes .fast .value
3636else :
3737 MOUNT_REFRESH_TIME = MountRefreshTimes [MOUNT_REFRESH_TIME ].value
38+
39+ def getCurrentVersion ():
40+ return "v2.0.0"
Original file line number Diff line number Diff line change 11import httpx
22from library .torbox import TORBOX_API_KEY
3+ from library .app import getCurrentVersion
34import time
45import logging
56import hashlib
67import json
78
89TORBOX_API_URL = "https://api.torbox.app/v1/api"
910TORBOX_SEARCH_API_URL = "https://search-api.torbox.app"
10- USER_AGENT = "TorBox-Media-Center/1.4 TorBox/1.0"
11+ USER_AGENT = f "TorBox-Media-Center/{ getCurrentVersion () } TorBox/1.0"
1112CACHE_TTL = 300 # cache time-to-live in seconds
1213_cache : dict [str , tuple [float , httpx .Response ]] = {}
1314
Original file line number Diff line number Diff line change 44python-dotenv
55parse-torrent-title
66fuse-python ; sys_platform != "win32" and sys_platform != "darwin"
7- git+https://github.com/libfuse/python-fuse; sys_platform == "darwin"
7+ git+https://github.com/libfuse/python-fuse; sys_platform == "darwin"
8+ GitPython
You can’t perform that action at this time.
0 commit comments