Skip to content

Commit

Permalink
Merge pull request #39 from ExtensiveJS/Support
Browse files Browse the repository at this point in the history
v2.3.0
  • Loading branch information
ExtensiveJS committed Aug 30, 2019
2 parents f51e5f3 + 5f561a3 commit 8117cb1
Show file tree
Hide file tree
Showing 24 changed files with 368 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ ui/backup/*.bak
ui/unzip/*.zip
*.sqlite3
ui/db.sqlite3
*.pyc
1 change: 1 addition & 0 deletions ui/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
url(r'changeSonarrStatus/',views.changeSonarrStatus),
url(r'skipEpisode/',views.skipEpisode),
url(r'runbackup/',views.runbackup),
url(r'changesSeasonExclude/',views.changesSeasonExclude),
url(r'^', include(router.urls))
]
25 changes: 23 additions & 2 deletions ui/api/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from jibarr.models import SiteSettings, Profile, ProfileRadarr, ProfileSonarr, ProfileLidarr, Logs, radarrMovie, RadarrMedia, sonarrShow, SonarrShowMedia, SonarrEpisodeMedia, ProfileSonarrEpisode
from jibarr.models import SiteSettings, Profile, ProfileRadarr, ProfileSonarr, ProfileLidarr, Logs, radarrMovie, RadarrMedia, sonarrShow, SonarrShowMedia, SonarrEpisodeMedia, ProfileSonarrEpisode, SonarrSeasonExclusions
from rest_framework import viewsets
from rest_framework.response import Response
from rest_framework import status
Expand Down Expand Up @@ -84,7 +84,7 @@ def post(self, request, pk):
prid = int(request.POST.get('prid'))
pid = request.POST.get('profile_id')
rt = request.POST.get('radarr_title')
pr = ProfileRadarr.objects.get(id=prid)
pr = ProfileRadarr.objects.get(radarr_id=prid,profile_id=pid)
pr.delete()
ret = "DelOK"
try:
Expand Down Expand Up @@ -533,5 +533,26 @@ def runbackup(request):
response.status_code = 500
return response

@api_view(['GET', 'POST'])
def changesSeasonExclude(request):
runType = 'none'
response = "Failed"
try:
runType = request.POST.get("runType")
series_id = request.POST.get("series_id")
profile_id = request.POST.get("profile_id")
seasonNumber = request.POST.get("seasonNumber")
if runType=='exclude':
Logs.objects.create(log_type='System',log_category='Sonarr',log_message='Excluding Season ## from profile AAAA.',log_datetime=datetime.utcnow().strftime("%b %d %Y %H:%M:%S"))
sse = SonarrSeasonExclusions.objects.create(series_id=series_id,seasonNumber=seasonNumber,profile_id=profile_id)
response = "OK"
elif runType=='include':
Logs.objects.create(log_type='System',log_category='Sonarr',log_message='Including Season ## in profile AAAA.',log_datetime=datetime.utcnow().strftime("%b %d %Y %H:%M:%S"))
sse = SonarrSeasonExclusions.objects.get(series_id=series_id,seasonNumber=seasonNumber,profile_id=profile_id)
sse.delete()
response = "OK"
except Exception as e:
pass
return Response(response)


Binary file modified ui/db.sqlite3
Binary file not shown.
8 changes: 8 additions & 0 deletions ui/dbupgrades/v2.2.0_to_v2.3.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ALTER TABLE jibarr_radarr_media ADD studio TEXT DEFAULT 'unknown';
UPDATE jibarr_radarr_media set studio = 'unknown';
ALTER TABLE jibarr_radarr_media ADD runtime TEXT DEFAULT 'unknown';
UPDATE jibarr_radarr_media set runtime = 'unknown';
ALTER TABLE jibarr_radarr_media ADD description TEXT DEFAULT '';
UPDATE jibarr_radarr_media set description = '';
CREATE TABLE "Profile_Sonarr_Season_Exclude" ('id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,'series_id' INTEGER NOT NULL DEFAULT 0,'profile_id' INTEGER NOT NULL DEFAULT 0,'seasonNumber' INTEGER NOT NULL DEFAULT 0)
UPDATE jibarr_settings set jibarr_version = '2.3.0';
25 changes: 22 additions & 3 deletions ui/jibarr/RadarrSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ def RadarrSync(forceload):
except:
pass

RadarrMedia.objects.create(radarr_id = rm.radarr_id,title = rm.title,title_slug = rm.title_slug,release_date = rm.release_date,folder_name = rm.folder_name,size = rm.size,file_name = rm.file_name,last_updt = rm.last_updt,rating = rm.rating,tmdbid = rm.tmdbid,imdbid = rm.imdbid,youtube = rm.youtube,website = rm.website,quality = rm.quality)
rm.studio = var["studio"]
rm.runtime = var["runtime"]
rm.description = var["overview"]

RadarrMedia.objects.create(radarr_id = rm.radarr_id,title = rm.title,title_slug = rm.title_slug,release_date = rm.release_date,folder_name = rm.folder_name,size = rm.size,file_name = rm.file_name,last_updt = rm.last_updt,rating = rm.rating,tmdbid = rm.tmdbid,imdbid = rm.imdbid,youtube = rm.youtube,website = rm.website,quality = rm.quality,studio = rm.studio,runtime = rm.runtime,description = rm.description)
#rm.save()
isSuccessful = True

Expand Down Expand Up @@ -172,6 +176,17 @@ def RadarrSync(forceload):
except:
pass

if rm.studio != var["studio"]:
wasUpdated = True
rm.studio = var["studio"]
if rm.runtime != var["runtime"]:
wasUpdated = True
rm.runtime = var["runtime"]
if rm.description != var['overview']:
wasUpdated = True
rm.description = var['overview']


#RadarrMedia.objects.create(radarr_id = rm.radarr_id,title = rm.title,title_slug = rm.title_slug,release_date = rm.release_date,folder_name = rm.folder_name,size = rm.size,file_name = rm.file_name,last_updt = rm.last_updt,rating = rm.rating,tmdbid = rm.tmdbid,imdbid = rm.imdbid,youtube = rm.youtube,website = rm.website,quality = rm.quality)
if wasUpdated:
try:
Expand Down Expand Up @@ -227,8 +242,12 @@ def RadarrSync(forceload):
except:
rm.quality = ""
pass

RadarrMedia.objects.create(radarr_id = rm.radarr_id,title = rm.title,title_slug = rm.title_slug,release_date = rm.release_date,folder_name = rm.folder_name,size = rm.size,file_name = rm.file_name,last_updt = rm.last_updt,rating = rm.rating,tmdbid = rm.tmdbid,imdbid = rm.imdbid,youtube = rm.youtube,website = rm.website,quality = rm.quality)

rm.studio = var["studio"]
rm.runtime = var["runtime"]
rm.description = var['overview']

RadarrMedia.objects.create(radarr_id = rm.radarr_id,title = rm.title,title_slug = rm.title_slug,release_date = rm.release_date,folder_name = rm.folder_name,size = rm.size,file_name = rm.file_name,last_updt = rm.last_updt,rating = rm.rating,tmdbid = rm.tmdbid,imdbid = rm.imdbid,youtube = rm.youtube,website = rm.website,quality = rm.quality,studio = rm.studio,runtime = rm.runtime,description = rm.description)
try:
Logs.objects.create(log_type='Sync',log_category='System',log_message='Added ' + rm.title + ' from Radarr',log_datetime=datetime.utcnow().strftime("%b %d %Y %H:%M:%S"))
except:
Expand Down
7 changes: 4 additions & 3 deletions ui/jibarr/SystemUpgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,22 @@ def upgradeDatabase(curVer,newVer):
Logs.objects.create(log_type='Upgrade',log_category='System',log_message='Database upgrade initiated.',log_datetime=datetime.utcnow().strftime("%b %d %Y %H:%M:%S"))
except:
pass

conn = sqlite3.connect('./ui/db.sqlite3')
try:
#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")
fd = open(os.path.join(d,"dbupgrades/v2.2.0_to_v2.3.0.txt"),"r")
sqlFile = fd.read()
fd.close()
conn = sqlite3.connect('./ui/db.sqlite3')

c = conn.cursor()
sqlCommands = sqlFile.split('\n')
for command in sqlCommands:
c.execute(command)
conn.commit()
except OperationalError as msg:
isSuccessful = False
conn.rollback()
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:
Expand Down
6 changes: 6 additions & 0 deletions ui/jibarr/models/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class radarrMovie(object):
isMonitored = False
isNewer = False
rating = 0
studio = ""
runtime = ""
description = ""
class Meta:
managed = False

Expand All @@ -54,6 +57,9 @@ class RadarrMedia(models.Model):
youtube = models.CharField(max_length=200)
website = models.CharField(max_length=200)
quality = models.CharField(max_length=200)
studio = models.CharField(max_length=200)
runtime = models.CharField(max_length=100)
description = models.CharField(max_length=2000)

objects = models.Manager()

Expand Down
14 changes: 13 additions & 1 deletion ui/jibarr/models/shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,23 @@ class Meta:
class sonarrSeason(object):
title = ''
episodes = [SonarrEpisodeMedia]
# default seasons to isMonitored = True
isMonitored = True

class Meta:
managed = False

class sonarrEpisodeList(list):
episodelist = []
def __init__(self):
self.episodelist = []
self.episodelist = []

class SonarrSeasonExclusions(models.Model):
series_id = models.IntegerField()
seasonNumber = models.IntegerField()
profile_id = models.IntegerField()

objects = models.Manager()

class Meta:
db_table = 'Profile_Sonarr_Season_Exclude'
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,14 +25,16 @@ 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;}
.qualityCallout {color:white;font-size:x-small;background-color:goldenrod;border-radius:5px;padding:2px 5px 2px 5px;margin:2px;cursor:pointer;}
.qualityCallout {color:white;font-size:x-small;background-color:goldenrod;border-radius:5px;padding:2px 5px 2px 5px;margin:2px;}
.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;}
.detailCallout {color:white;font-size:x-small;background-color:#6cb1ee;border-radius:5px;padding:2px 5px 2px 5px;}

/*.ui-dialog-titlebar {display: none;} */
.ui-widget-overlay {opacity: .50;filter: Alpha(Opacity=30);}

Expand Down
1 change: 1 addition & 0 deletions ui/jibarr/templates/jibarr/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{% else %}
<i class="glyphicon glyphicon-star-empty" style="float:right;cursor:pointer;" onclick="addMonitor({{ val.r_id }},'Some Title');"></i>
{% endif %}
<i class="glyphicon glyphicon-search" style="float:right;cursor:pointer;margin-right:3px;" onclick="location.replace('/jibarr/moviedetails?id={{ val.r_id }}');"></i>
</div>
</div>
{% if system_settings.isConnected %}
Expand Down
117 changes: 117 additions & 0 deletions ui/jibarr/templates/jibarr/moviedetails.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{% extends "./base.html" %}
{% load static %}
{% block title %}{{ movie.title }}{% endblock title %}
{% block javascript%}
{% if system_settings.isRadarrConnected %}
<style>
BODY {
background: url('{{ system_settings.radarr_path }}/MediaCover/{{ movie.radarr_id }}/fanart.jpg') no-repeat fixed;
background-size: cover;
}
</style>
{% endif %}
{% endblock javascript %}
{% block content %}

<div class='CONTAINER' style="background-color:#1F1E1E;color:whitesmoke;padding-left:20px;min-height:150px;box-shadow: 0 0 10px 1px #aaa;">
<div style="float:left;margin:20px 10px 10px 10px;">
{% if system_settings.isRadarrConnected %}
<img src="{{ system_settings.radarr_path }}/MediaCover/{{ movie.radarr_id }}/poster.jpg" style="width:190px;" />
{% else %}
<img src="{% static 'jibarr/images/no_image.png' %}" style="width:50px;cursor:pointer;" />
{% endif %}
</div>
<div>
<div style="float:right;">
{% if movie.isMonitored %}
<i class="glyphicon glyphicon-star" style='cursor:pointer;font-size:x-large;' title="Monitored" onclick="delMonitor({{ movie.radarr_id }});" ></i>
{% else %}
<i class="glyphicon glyphicon-star-empty" style='cursor:pointer;font-size:x-large;' title="Un-Monitored" onclick="addMonitor({{ movie.radarr_id }},'{{ movie.title }}');"></i>
{% endif %}
</div>
<h2>{{ movie.title }} ({{ movie.year }})</h2>
</div>
<p style="margin-bottom:20px;">Description goes here - Description Goes Here.</p>
<div>
<span class="detailCallout">{{ movie.studio }}</span>
<span class="detailCallout">{{ movie.runtime }} minutes</span>
<span class="detailCallout">{{ movie.rating }} / 10</span>
<span class="qualityCallout" title="Quality">{{ movie.quality }}</span>
<span class="detailCallout">Released {{ movie.release_date }}</span>
<br />
{% if movie.tmdbid %}
<span class="siteCallout"><a href='http://themoviedb.org/movie/{{ movie.tmdbid }}' target="_new">The Movie DB</a></span>
{% endif %}
{% if movie.imdbid %}
<span class="siteCallout"><a href='http://imdb.com/title/{{ movie.imdbid }}' target="_new">IMDB</a></span>
{% endif %}
{% if movie.youtube %}
<span class="siteCallout"><a href='http://youtube.com/watch?v={{ movie.youtube }}' target="_new">Trailer</a></span>
{% endif %}
{% if movie.website %}
<span class="siteCallout"><a href='http://{{ movie.website }}' target="_new">Homepage</a></span>
{% endif %}
{% if movie.tmdbid %}
<span class="siteCallout"><a href='http://trakt.tv/search/tmdb/{{ movie.tmdbid }}?id_type=movie' target="_new">Trakt</a></span>
{% endif %}
{% if system_settings.isRadarrConnected %}
<span class="siteCallout"><a href='{{ system_settings.radarr_path }}/movies/{{ movie.title_slug }}' target="_new">RADARR</a></span>
{% endif %}
</div>
</div>

<a href="{{ system_settings.radarr_path }}/movies/{{ movie.title_slug }}" target="_new">{{ movie.title }}</a>

{% endblock content %}
{% block postbody %}
<script>
$(function () {
});
function addMonitor(rid,title) {
$.ajax({
url : '/api/profileradarr/add/',
type : 'POST',
data: {
profile_id: {{ system_profile.id }},
radarr_id: rid,
radarr_title: title
},
success: function(data)
{
location.reload();
},
fail: function(xhr, textStatus, errorThrown){
alert('request failed');
}
});
}
function delMonitor(id) {
if(confirm('are you sure?')){
$.ajax({
url : '/api/profileradarr/delete/',
type : 'POST',
data: {
prid: id,
profile_id: {{ prof_id }},
radarr_title: 'Some Title'
},
success: function(data)
{
if(data == "DelOK"){
location.reload();
} else {
alert("Data not DelOK = " + data);
};
},
error:function (xhr, ajaxOptions, thrownError){
alert('request error' + xhr.status)
},
fail: function(xhr, textStatus, errorThrown){
alert('request failed');
}
});
}
}

</script>
{% endblock postbody %}
2 changes: 1 addition & 1 deletion ui/jibarr/templates/jibarr/movies.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% endif %}
</div>
<div style="float:left;">
<a href="{{ system_settings.radarr_path }}/movies/{{ val.titleSlug }}" target="_new">{{ val.title }}</a>
<a href="/jibarr/moviedetails?id={{ val.r_id }}">{{ val.title }}</a>
</div>
<div id="divAction_{{ val.r_id }}" style="width:65px;float:right;margin-right:0px;text-align:center;font-size:medium;">
{% if val.isMonitored %}
Expand Down
Loading

0 comments on commit 8117cb1

Please sign in to comment.