Added check for update
This commit is contained in:
@@ -3,7 +3,8 @@ import re
|
|||||||
from markupsafe import Markup
|
from markupsafe import Markup
|
||||||
|
|
||||||
from app.classes import AudioProfile
|
from app.classes import AudioProfile
|
||||||
from app import app
|
from app import app, functions, read_dev_build_file
|
||||||
|
from .version import __version__
|
||||||
|
|
||||||
filters = {}
|
filters = {}
|
||||||
|
|
||||||
@@ -55,6 +56,37 @@ def audioprofile(text: str, path: str) -> Markup:
|
|||||||
)
|
)
|
||||||
return Markup(audio_profile_html)
|
return Markup(audio_profile_html)
|
||||||
|
|
||||||
|
@template_filter('version_check')
|
||||||
|
def version_check(version: str) -> Markup:
|
||||||
|
version = f"{__version__}{read_dev_build_file()}"
|
||||||
|
# if version contains a dash and the text after the dash is LOCAL, return version as a blue badge
|
||||||
|
if app.config['CHECK_FOR_UPDATES']:
|
||||||
|
if '-' in version and version.split('-')[1] == 'LOCAL':
|
||||||
|
return Markup(f"<span class='badge rounded-pill bg-primary'>{version}</span>")
|
||||||
|
# else if the version string contains a dash and the text after the dash is not LOCAL, check whether it contains another dash (like in e.g. v0.1.7-dev-89a1bc2) and split both parts
|
||||||
|
elif '-' in version and version.split('-')[1] != 'LOCAL' :
|
||||||
|
branch, commit_sha = version.split('-')[1], version.split('-')[2]
|
||||||
|
nra,url = functions.get_latest_dev_releases(branch_name = branch, commit_sha = commit_sha)
|
||||||
|
if nra:
|
||||||
|
return Markup(f"<a href='{url}' target='_blank'><span class='badge rounded-pill text-bg-warning btn-pulsing' data-bs-toggle='tooltip' title='An update for the {branch} branch is available.'>{version}</span></a>")
|
||||||
|
else:
|
||||||
|
return Markup(f"<span class='badge rounded-pill text-bg-secondary'>{version}</span>")
|
||||||
|
else:
|
||||||
|
nra,url = functions.get_latest_release(version)
|
||||||
|
if nra:
|
||||||
|
return Markup(f"<a href='{url}' target='_blank'><span class='badge rounded-pill text-bg-warning btn-pulsing' data-bs-toggle='tooltip' title='An update is available.'>{version}</span></a>")
|
||||||
|
|
||||||
|
|
||||||
|
return Markup(f"<span class='badge rounded-pill text-bg-primary'>{version}</span>")
|
||||||
|
else:
|
||||||
|
return Markup(f"<span class='badge rounded-pill text-bg-info'>{version}</span>")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@template_filter('jellyfin_link')
|
@template_filter('jellyfin_link')
|
||||||
def jellyfin_link(jellyfin_id: str) -> Markup:
|
def jellyfin_link(jellyfin_id: str) -> Markup:
|
||||||
|
|||||||
@@ -207,3 +207,41 @@ def get_longest_substring(input_string):
|
|||||||
substrings = re.split(pattern, input_string)
|
substrings = re.split(pattern, input_string)
|
||||||
longest_substring = max(substrings, key=len, default="")
|
longest_substring = max(substrings, key=len, default="")
|
||||||
return longest_substring
|
return longest_substring
|
||||||
|
|
||||||
|
@cache.memoize(timeout=3600*2)
|
||||||
|
def get_latest_dev_releases(branch_name :str, commit_sha : str):
|
||||||
|
try:
|
||||||
|
response = requests.get('https://api.github.com/repos/kamilkosek/jellyplist/releases')
|
||||||
|
if response.status_code == 200:
|
||||||
|
data = response.json()
|
||||||
|
latest_release = None
|
||||||
|
for release in data:
|
||||||
|
if branch_name in release['tag_name']:
|
||||||
|
if latest_release is None or release['published_at'] > latest_release['published_at']:
|
||||||
|
latest_release = release
|
||||||
|
|
||||||
|
if latest_release:
|
||||||
|
response = requests.get(f'https://api.github.com/repos/kamilkosek/jellyplist/git/ref/tags/{latest_release["tag_name"]}')
|
||||||
|
if response.status_code == 200:
|
||||||
|
data = response.json()
|
||||||
|
if commit_sha != data['object']['sha'][:7]:
|
||||||
|
return True, latest_release['html_url']
|
||||||
|
|
||||||
|
|
||||||
|
return False, ''
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
app.logger.error(f"Error fetching latest version: {str(e)}")
|
||||||
|
return False, ''
|
||||||
|
|
||||||
|
@cache.memoize(timeout=3600*2)
|
||||||
|
def get_latest_release(tag_name :str):
|
||||||
|
try:
|
||||||
|
response = requests.get('https://api.github.com/repos/kamilkosek/jellyplist/releases/latest')
|
||||||
|
if response.status_code == 200:
|
||||||
|
data = response.json()
|
||||||
|
if data['tag_name'] != tag_name:
|
||||||
|
return True, data['html_url']
|
||||||
|
return False, ''
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
app.logger.error(f"Error fetching latest version: {str(e)}")
|
||||||
|
return False,''
|
||||||
@@ -32,7 +32,7 @@ class Config:
|
|||||||
LIDARR_URL = os.getenv('LIDARR_URL','')
|
LIDARR_URL = os.getenv('LIDARR_URL','')
|
||||||
LIDARR_MONITOR_ARTISTS = os.getenv('LIDARR_MONITOR_ARTISTS','false').lower() == 'true'
|
LIDARR_MONITOR_ARTISTS = os.getenv('LIDARR_MONITOR_ARTISTS','false').lower() == 'true'
|
||||||
MUSIC_STORAGE_BASE_PATH = os.getenv('MUSIC_STORAGE_BASE_PATH')
|
MUSIC_STORAGE_BASE_PATH = os.getenv('MUSIC_STORAGE_BASE_PATH')
|
||||||
|
CHECK_FOR_UPDATES = os.getenv('CHECK_FOR_UPDATES','true').lower() == 'true'
|
||||||
# SpotDL specific configuration
|
# SpotDL specific configuration
|
||||||
SPOTDL_CONFIG = {
|
SPOTDL_CONFIG = {
|
||||||
'cookie_file': '/jellyplist/cookies.txt',
|
'cookie_file': '/jellyplist/cookies.txt',
|
||||||
|
|||||||
@@ -9,10 +9,12 @@ body {
|
|||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.top-bar {
|
.top-bar {
|
||||||
background-color: #1a1d21;
|
background-color: #1a1d21;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar h3 {
|
.sidebar h3 {
|
||||||
color: white;
|
color: white;
|
||||||
padding-left: 15px;
|
padding-left: 15px;
|
||||||
@@ -50,14 +52,18 @@ body {
|
|||||||
width: 140px;
|
width: 140px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.logo img {
|
.logo img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 1600px) {
|
@media screen and (min-width: 1600px) {
|
||||||
.modal-dialog {
|
.modal-dialog {
|
||||||
max-width: 90%; /* New width for default modal */
|
max-width: 90%;
|
||||||
|
/* New width for default modal */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchbar {
|
.searchbar {
|
||||||
margin-bottom: auto;
|
margin-bottom: auto;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
@@ -101,3 +107,21 @@ body {
|
|||||||
color: white;
|
color: white;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-pulsing {
|
||||||
|
animation: pulse 2s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
transform: scale(1.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -116,7 +116,7 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<span class="fixed-bottom m-3">{{version}}</span>
|
<span class="fixed-bottom m-3 ms-5">{{version | version_check}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Main content with toggle button for mobile sidebar -->
|
<!-- Main content with toggle button for mobile sidebar -->
|
||||||
|
|||||||
Reference in New Issue
Block a user