Skip to content

Commit

Permalink
Merge pull request #38 from ExtensiveJS/Support
Browse files Browse the repository at this point in the history
v2.2.0 Update - Show Status
  • Loading branch information
ExtensiveJS committed May 23, 2019
2 parents 9ca1a53 + 679d7c8 commit f51e5f3
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 7 deletions.
Binary file modified ui/db.sqlite3
Binary file not shown.
3 changes: 3 additions & 0 deletions ui/dbupgrades/v2.1.2_to_v2.2.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE jibarr_sonarr_show ADD status TEXT DEFAULT 'ended';
UPDATE jibarr_sonarr_show set status = 'continuing';
UPDATE jibarr_settings set jibarr_version = '2.2.0';
20 changes: 20 additions & 0 deletions ui/jibarr/SonarrSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,27 @@ def SonarrSync(forceload):
# do Series Episode loop
if isSuccessful:
isSuccessful = LoopSeries(forceload)
if isSuccessful:
checkShowStatus()

return isSuccessful

def checkShowStatus():
isSuccessful = True
system_settings = SiteSettings.objects.all()[:1].get()
for ssm in SonarrShowMedia.objects.all():
try:
urlString = system_settings.sonarr_path + "/api/series/" + str(ssm.sonarr_id) + "/?apikey=" + system_settings.sonarr_apikey
data = urlopen(urlString).read()
output = json.loads(data)
newStatus = output["status"]
oldStatus = ssm.status
if oldStatus != newStatus:
ssm.status = newStatus
ssm.save()
Logs.objects.create(log_type='Sync',log_category='Sonarr',log_message='Sonarr show (' + ssm.title + ') changed from (' + oldStatus + ') to (' + newStatus + ')',log_datetime=datetime.utcnow().strftime("%b %d %Y %H:%M:%S"))
except Exception as e:
pass
return isSuccessful

def LoopSeries(forceload):
Expand Down
9 changes: 6 additions & 3 deletions ui/jibarr/SystemUpgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,25 @@ def upgradeDatabase(curVer,newVer):
pass

try:
fd = open("./unzip/jibarr-master/jibarr/ui/dbupgrades/v" + curVer + "_to_v" + newVer + ".txt","r")
#fd = open("./dbupgrades/v" + curVer + "_to_v" + newVer + ".txt","r")
d = dirname(dirname(abspath(__file__)))
fd = open(os.path.join(d,"dbupgrades/v2.1.2_to_v2.2.0.txt"),"r")
sqlFile = fd.read()
fd.close()
conn = sqlite3.connect('./ui/db.sqlite3')
c = conn.cursor()
sqlCommands = sqlFile.split(';')
sqlCommands = sqlFile.split('\n')
for command in sqlCommands:
c.execute(command)
conn.commit()
except OperationalError as msg:
isSuccessful = False
try:
Logs.objects.create(log_type='Upgrade',log_category='System',log_message='Database upgrade error: ' + msg,log_datetime=datetime.utcnow().strftime("%b %d %Y %H:%M:%S"))
except:
pass
pass
except:
except Exception as e:
isSuccessful = False
pass

Expand Down
Binary file modified ui/jibarr/models/__pycache__/shows.cpython-37.pyc
Binary file not shown.
2 changes: 2 additions & 0 deletions ui/jibarr/models/shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class sonarrShow(object):
episodeFileCount = 0
description = ""
isMonitored = False
status = ""

class Meta:
managed = False
Expand All @@ -72,6 +73,7 @@ class SonarrShowMedia(models.Model):
episodeCount = models.IntegerField()
episodeFileCount = models.IntegerField()
description = models.CharField(max_length=1000)
status = models.CharField(max_length=20)

objects = models.Manager()

Expand Down
4 changes: 3 additions & 1 deletion ui/jibarr/static/jibarr/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ li a { color: green; }
.movieImageContainer:hover .overlayBottom {bottom: 0px;left: 0px;height: 45px;opacity: 0.75;background-color: whitesmoke;}
.overlayTopText {color: black;font-weight:bold;font-size:x-large;padding-right:5px;padding-top:2px;}
.overlayBottomText {color: black;font-size:small;padding-right:5px;padding-top:2px;text-align:center;}
.siteCallout {color:white;font-size:x-small;background-color:#337ab7;border-radius:5px;padding:2px 5px 2px 5px;cursor:pointer;}
.qualityCallout {color:white;font-size:x-small;background-color:goldenrod;border-radius:5px;padding:2px 5px 2px 5px;margin:2px;cursor:pointer;}
.seasonCallout {color:white;font-size:smaller;background-color:steelblue;border-radius:5px;padding:2px 5px 2px 5px;margin:2px;}
.episodeCallout {color:white;font-size:smaller;background-color:yellowgreen;border-radius:5px;padding:2px 5px 2px 5px;margin:2px;cursor:pointer;}
.siteCallout {color:white;font-size:x-small;background-color:#337ab7;border-radius:5px;padding:2px 5px 2px 5px;cursor:pointer;}
.siteCallout A {color:white;}
.siteCallout A:HOVER {text-decoration: none;}
.continuingCallout {color:white;font-size:x-small;background-color:#129e0e;border-radius:5px;padding:2px 5px 2px 5px;cursor:pointer;}
.endedCallout {color:white;font-size:x-small;background-color:#c55413;border-radius:5px;padding:2px 5px 2px 5px;cursor:pointer;}
/*.ui-dialog-titlebar {display: none;} */
.ui-widget-overlay {opacity: .50;filter: Alpha(Opacity=30);}

Expand Down
7 changes: 7 additions & 0 deletions ui/jibarr/templates/jibarr/showdetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ <h2>{{ show.title }}</h2>
<span class="siteCallout"><a href='http://imdb.com/title/{{ show.imdbId }}' target="_new">IMDB</a></span>
{% endif %}
</div>
<div style="padding-top:5px;">
{% if show.status == 'continuing' %}
<span class="continuingCallout">Continuing</span>
{% else %}
<span class="endedCallout">Ended</span>
{% endif %}
</div>
</div>

{% for seas in show.seasons %}
Expand Down
5 changes: 5 additions & 0 deletions ui/jibarr/templates/jibarr/shows.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
{% if val.imdbId %}
<span class="siteCallout"><a href='http://imdb.com/title/{{ val.imdbId }}' target="_new">IMDB</a></span>
{% endif %}
{% if val.status == 'continuing' %}
<span class="continuingCallout">Continuing</span>
{% else %}
<span class="endedCallout">Ended</span>
{% endif %}
</div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion ui/jibarr/templates/jibarr/updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
<div style="font-size:small;padding:10px;font-family:Verdana, Geneva, Tahoma, sans-serif;">
<div style="padding-bottom:20px;">
<div style="padding-bottom:10px;">
<h4 style="border-bottom:1px solid lightgrey;">2.1.2 - May ??, 2019</h4>
<h4 style="border-bottom:1px solid lightgrey;">2.2.0 - May 13, 2019</h4>
<div><span class="newTag">NEW</span><span class="systemTag">Sonarr</span>Shows now show their Status (continuing/ended).</div>
</div>
<div style="padding-bottom:10px;">
<h4 style="border-bottom:1px solid lightgrey;">2.1.2 - May 13, 2019</h4>
<div><span class="updateTag">FIXED</span><span class="systemTag">Sonarr</span>Fixed the monitored indicator and clicking on Home page.</div>
<div><span class="updateTag">FIXED</span><span class="systemTag">System</span>Fixed the title on Home page.</div>
<div><span class="newTag">NEW</span><span class="systemTag">Sonarr</span>Season episode lists load collapsed with expand option.</div>
Expand Down
Binary file modified ui/jibarr/views/__pycache__/shows.cpython-37.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions ui/jibarr/views/shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def get_show_info(system_settings, prof):
epCnt = epCnt + var.episodeCount
ss.isMonitored = False
ss.isNewer = False
ss.status = var.status

#mId = 0
for ps in psList:
Expand Down
2 changes: 1 addition & 1 deletion ui/ui/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@

STATIC_URL = '/static/'

CODE_VERSION = "2.1.2"
CODE_VERSION = "2.2.0"
20 changes: 19 additions & 1 deletion ui/ui/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from django.core.wsgi import get_wsgi_application
from django.conf import settings
from datetime import datetime
from jibarr import SystemUpgrade

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'ui.settings')

Expand All @@ -21,7 +22,24 @@
settings.isConnected = False
settings.isSonarrConnected = False
system_settings = SiteSettings.objects.all()[:1].get()


# get db version
dbVer = system_settings.jibarr_version
# get settings version
appVer = settings.CODE_VERSION
# compare
if dbVer != appVer:
# backup DB
try:
SystemUpgrade.backupDatabase()
except Exception as e:
pass
# run update
try:
SystemUpgrade.upgradeDatabase(dbVer,appVer)
except Exception as e:
pass

try:
data = urlopen(system_settings.radarr_path + "/api/system/status/?apikey=" + system_settings.radarr_apikey).read()
json.loads(data)
Expand Down

0 comments on commit f51e5f3

Please sign in to comment.