Skip to content

Commit

Permalink
Merge pull request #212 from JasonHHouse/bugfix/fixing_broken_auto_run
Browse files Browse the repository at this point in the history
Bugfix/fixing broken auto run
  • Loading branch information
JasonHHouse authored Jan 22, 2021
2 parents 5af57bb + 3c9e14c commit 0bddd3e
Show file tree
Hide file tree
Showing 27 changed files with 198 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.9</version>
<version>0.8.10</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
59 changes: 59 additions & 0 deletions Core/src/main/java/com/jasonhhouse/gaps/PlexLibraryComparator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package com.jasonhhouse.gaps;

import com.jasonhhouse.plex.libs.PlexLibrary;
import java.util.Comparator;
import java.util.function.Function;
import java.util.function.ToDoubleFunction;
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;

public class PlexLibraryComparator implements Comparator<PlexLibrary> {
@Override
public int compare(PlexLibrary o1, PlexLibrary o2) {
return o1.getTitle().compareTo(o2.getTitle());
}

@Override
public Comparator<PlexLibrary> reversed() {
throw new UnsupportedOperationException();
}

@Override
public Comparator<PlexLibrary> thenComparing(Comparator<? super PlexLibrary> other) {
throw new UnsupportedOperationException();
}

@Override
public <U> Comparator<PlexLibrary> thenComparing(Function<? super PlexLibrary, ? extends U> keyExtractor, Comparator<? super U> keyComparator) {
throw new UnsupportedOperationException();
}

@Override
public <U extends Comparable<? super U>> Comparator<PlexLibrary> thenComparing(Function<? super PlexLibrary, ? extends U> keyExtractor) {
throw new UnsupportedOperationException();
}

@Override
public Comparator<PlexLibrary> thenComparingInt(ToIntFunction<? super PlexLibrary> keyExtractor) {
throw new UnsupportedOperationException();
}

@Override
public Comparator<PlexLibrary> thenComparingLong(ToLongFunction<? super PlexLibrary> keyExtractor) {
throw new UnsupportedOperationException();
}

@Override
public Comparator<PlexLibrary> thenComparingDouble(ToDoubleFunction<? super PlexLibrary> keyExtractor) {
throw new UnsupportedOperationException();
}
}
14 changes: 9 additions & 5 deletions Core/src/main/java/com/jasonhhouse/gaps/PlexServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.jasonhhouse.plex.libs.PlexLibrary;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.validation.constraints.NotNull;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand All @@ -36,7 +36,7 @@ public final class PlexServer {
private Integer port;

public PlexServer() {
plexLibraries = new ArrayList<>();
plexLibraries = new SortedList<>(new PlexLibraryComparator());
}

public PlexServer(String friendlyName, String machineIdentifier, String plexToken, String address, Integer port) {
Expand All @@ -45,7 +45,7 @@ public PlexServer(String friendlyName, String machineIdentifier, String plexToke
this.plexToken = plexToken;
this.address = address;
this.port = port;
plexLibraries = new ArrayList<>();
plexLibraries = new SortedList<>(new PlexLibraryComparator());
}

public String getFriendlyName() {
Expand All @@ -65,10 +65,14 @@ public void setMachineIdentifier(String machineIdentifier) {
}

public List<PlexLibrary> getPlexLibraries() {
Collections.sort(plexLibraries);
return plexLibraries;
}

public void setPlexLibraries(@NotNull List<PlexLibrary> plexLibraries) {
this.plexLibraries.clear();
this.plexLibraries.addAll(plexLibraries);
}

public String getPlexToken() {
return plexToken;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/src/main/java/com/jasonhhouse/gaps/Schedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@JsonDeserialize(using = ScheduleDeserializer.class)
public enum Schedule {

HOURLY("Hourly", "0 35 * * * ?", 0),
HOURLY("Hourly", "0 49 * * * ?", 0),
DAILY_4AM("Daily", "0 0 4 * * ?", 1),
EVERY_MONDAY("Weekly", "0 0 4 * * MON", 2),
EVERY_TWO_WEEKS("Bi-weekly", "0 0 4 1,15 * ?", 3),
Expand Down
90 changes: 90 additions & 0 deletions Core/src/main/java/com/jasonhhouse/gaps/SortedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Copyright 2020 Jason H House
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

package com.jasonhhouse.gaps;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;

public class SortedList<T> extends ArrayList<T> {

private static final long serialVersionUID = -441423857950125427L;

private final Comparator<T> comparator;

public SortedList(Class<T> clazz) {
super();
if (!Comparable.class.isAssignableFrom(clazz)) {
throw new ClassCastException(clazz + " does not implement comparable");
}
// Create comparator using the comparable interface.
this.comparator = new Comparator<T>() {
@SuppressWarnings("unchecked")
@Override
public int compare(T o1, T o2) {
return ((Comparable<? super T>) o1).compareTo(o2);
}
};
}

public SortedList(Comparator<T> comparator) {
super();
this.comparator = comparator;
}

/**
* Add the element to this sorted list in a sorted order.
*
* @param e The element
* @return Always true
*/
@Override
public boolean add(T e) {
int insertPoint = Collections.binarySearch(this, e, comparator);
if (insertPoint < 0) {
insertPoint = (insertPoint * -1) - 1;
}
super.add(insertPoint, e);
return true;

}

/**
* @deprecated Function ignores the index and insert the element in the correct order
*/
@Deprecated
public void add(int index, T element) {
add(element);
}

/**
* Add all elements from the collection to this sorted list in a sorted order.
*
* @param c The collection holding all elements to add to this sorted list. The elements in the collection needn't to be in sorted order
* @return Always true
*/
@Override
public boolean addAll(Collection<? extends T> c) {
for (T s : c) {
add(s);
}
return true;
}

/**
* @deprecated Function ignores the index and insert the elements in the correct order
*/
@Deprecated
public boolean addAll(int index, Collection<? extends T> c) {
return addAll(c);
}
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.10.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.10.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.10.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.raspbian
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.10.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.riscv64
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN mkdir -p /usr/app && chmod 777 /usr/data

WORKDIR /usr/app

COPY GapsWeb/target/GapsWeb-0.8.9.jar /usr/app/gaps.jar
COPY GapsWeb/target/GapsWeb-0.8.10.jar /usr/app/gaps.jar

COPY start.sh /usr/app/

Expand Down
2 changes: 1 addition & 1 deletion GapsAsJar/gaps.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ RMDIR /r $INSTDIR
SectionEnd

# name the installer
OutFile "gaps-0.8.9-installer.exe"
OutFile "gaps-0.8.10-installer.exe"
2 changes: 1 addition & 1 deletion GapsWeb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.9</version>
<version>0.8.10</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) {
List<PlexLibrary> plexLibraries = mediaContainer.getPlexLibraries().stream().filter(plexLibrary -> plexLibrary.getType().equalsIgnoreCase("movie")).collect(Collectors.toList());

LOGGER.info("{} Plex libraries found", plexLibraries.size());
plexServer.getPlexLibraries().clear();
plexServer.getPlexLibraries().addAll(plexLibraries);
plexServer.setPlexLibraries(plexLibraries);
return Payload.PLEX_LIBRARIES_FOUND.setExtras("size():" + plexLibraries.size());
} catch (IOException e) {
String reason = String.format("Error connecting to Plex to get library list: %s", url);
Expand Down
2 changes: 1 addition & 1 deletion GapsWeb/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.8.9
version: 0.8.10
storageFolder: /usr/data
properties:
rssFeed: rssFeed.json
Expand Down
2 changes: 1 addition & 1 deletion GapsWeb/src/main/resources/templates/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<img src="/images/final-2.svg" alt="Gaps Logo" style="width:50%;height:50%;" class="center">

<h3 class="top-margin">About</h3>
<h4 class="top-margin text-primary">v0.8.9</h4>
<h4 class="top-margin text-primary">v0.8.10</h4>

<p class="text-muted">Gaps searches through your Plex Server. It then queries
for known
Expand Down
2 changes: 1 addition & 1 deletion GapsWeb/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<div class="container bottom-margin">
<img src="/images/final-2.svg" alt="Gaps Logo" style="width:50%;height:50%;" class="center">

<h3 class="top-margin">v0.8.9</h3>
<h3 class="top-margin">v0.8.10</h3>

<p class="text-muted">Gaps searches through your Plex Server. It then queries
for known
Expand Down
5 changes: 5 additions & 0 deletions GapsWeb/src/main/resources/templates/updates.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
<img src="/images/final-2.svg" alt="Gaps Logo" style="width:50%;height:50%;" class="center">

<h3 class="top-margin">Updates</h3>
<h4 class="top-margin text-primary">v0.8.10</h4>
<ul class="text-muted">
<li>Fixing exception that prevented multi plex server automatic scans</li>
</ul>

<h4 class="top-margin text-primary">v0.8.9</h4>
<ul class="text-muted">
<li>Reduced bugs and code rot</li>
Expand Down
2 changes: 1 addition & 1 deletion Plex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.9</version>
<version>0.8.10</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion RadarrV3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>Gaps</artifactId>
<groupId>com.jasonhhouse</groupId>
<version>0.8.9</version>
<version>0.8.10</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion application-custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ info:
app:
name: Gaps
description: Gaps searches through your Plex Server or local folders for all movies, then queries for known movies in the same collection. If those movies don't exist in your library, Gaps will recommend getting those movies, legally of course.
version: 0.8.9
version: 0.8.10
storageFolder: /{CUSTOM_FOLDER} #Change to folder that gaps has permission to read, write, and delete in.
properties:
rssFeed: rssFeed.json
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -e
VERSION=0.8.9
VERSION=0.8.10
JAR_VERSION="GapsWeb/target/GapsWeb-$VERSION.jar"
ZIP_VERSION="GapsAsJar-$VERSION.zip"
npm ci
Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ call npm run uglifyjs-pages
call mvn clean install
del GapsOnWindows\*.jar
del GapsOnWindows\README.md
copy GapsWeb\target\GapsWeb-0.8.9.jar GapsOnWindows\gaps.jar
copy GapsWeb\target\GapsWeb-0.8.10.jar GapsOnWindows\gaps.jar
copy README.md GapsOnWindows\
cd GapsOnWindows
makensis gaps.nsi
2 changes: 1 addition & 1 deletion cypress/integration/about/about.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Verify About Page', () => {
.should('have.text', 'About');

cy.get('.container > :nth-child(3)')
.should('have.text', 'v0.8.9');
.should('have.text', 'v0.8.10');

cy.get('.container > :nth-child(6)')
.should('have.text', 'Software');
Expand Down
1 change: 1 addition & 0 deletions docker-compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ services:
#javaInitialHeapSize: 150M
ports:
- 8484:8484
- 5005:5005
restart: unless-stopped
expose:
- "32400"
Expand Down
Loading

0 comments on commit 0bddd3e

Please sign in to comment.