Skip to content

Commit

Permalink
Version 0.6.3
Browse files Browse the repository at this point in the history
* Added support for video games.
* Made the application version and name always stay consistent.
* Fixed a bug which caused the text for seasons 10 and above to be cutoff.
* Fixed movies showing "Other" as media type.
* Fixed a crash that could sometimes occur.
  • Loading branch information
samsalmag committed Dec 27, 2020
1 parent 59835dd commit 4b73e8d
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 65 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
# Rating Reader

Rating Reader is a program that reads movie and TV show scores from [IMDb](https://www.imdb.com) and conveniently displays them in a spoiler-free way. Needs an internet connection to work correctly.
Rating Reader is an application that reads media scores from [IMDb](https://www.imdb.com) and conveniently displays them in a spoiler-free way.
Needs an internet connection to work.
<br />
<br />
By Sam Salek

## How to download
The most up-to-date version of RatingReader.exe is located under builds/_current. Simply select the file and press the "Download" button to start downloading.
The most up-to-date version of RatingReader.exe is located under "builds/_current", a .jar version of the application also exists in the same place for those inclined.
Simply select the file and press the "Download" button to start downloading (a warning may pop up before/during the download. This is perfectly normal, however the application itself is not harmful to your computer in any way. The source code is always available if skeptical).
Older builds also exist beside the "_current" folder, these are however not recommended as they can be unstable and/or buggy.


## Update Log
#### 0.6.0:
#### 0.6.3 (27/12/20):
* Added support for video games.
* Made the application version and name always stay consistent.
* Fixed a bug which caused the text for seasons 10 and above to be cutoff.
* Fixed movies showing "Other" as media type.
* Fixed a crash that could sometimes occur.

#### 0.6.0 (22/12/20):
* Episodes without a rating is now also displayed (with rating "NA").
* Episodes now correctly displays their respective episode name.
* Added functionality for Miniseries' and media that necessarily isn't a series or movie.
* Optimizations and overall better performance.
* Minor UI changes and optimizations.
* Few bug fixes.

#### 0.5.0:
#### 0.5.0 (14/11/20):
* Initial version release.
Binary file not shown.
Binary file not shown.
Binary file added builds/_current/RatingReader_0.6.3.exe
Binary file not shown.
Binary file added builds/_current/ratingreader-0.6.3.jar
Binary file not shown.
29 changes: 25 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

<groupId>com.zemahzalek</groupId>
<artifactId>ratingreader</artifactId>
<version>0.6.0</version>
<version>${dev.version}</version>
<packaging>jar</packaging>
<name>RatingReader</name>
<!--suppress UnresolvedMavenProperty --> <!-- Because of stupid error-->
<name>${dev.name}</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -73,7 +74,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>com.zemahzalek.ratingreader.RatingReader</mainClass>
<mainClass>com.zemahzalek.ratingreader.view.RatingReader</mainClass>
</configuration>
</plugin>

Expand Down Expand Up @@ -129,7 +130,7 @@
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/RatingReader-${project.version}.exe</outfile>
<outfile>target/${dev.executable.name}_${project.version}.exe</outfile>
<jar>target/${project.artifactId}-${project.version}.jar</jar>
<!-- if <dontWrapJar>true</dontWrapJar> change to this conf <jar>${project.artifactId}-${project.version}.jar</jar> -->
<dontWrapJar>false</dontWrapJar>
Expand All @@ -149,6 +150,26 @@
</executions>
</plugin>

<!-- Allows the use of a .properties file -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>src/main/resources/dev.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
2 changes: 2 additions & 0 deletions src/main/java/com/zemahzalek/ratingreader/Main.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.zemahzalek.ratingreader;

import com.zemahzalek.ratingreader.view.RatingReader;

public class Main {

public static void main(String[] args) {
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/com/zemahzalek/ratingreader/MediaType.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.zemahzalek.ratingreader;
package com.zemahzalek.ratingreader.controller;

import com.zemahzalek.ratingreader.view.EpisodeItem;
import com.zemahzalek.ratingreader.model.Media;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
Expand Down Expand Up @@ -117,7 +119,7 @@ public void run() {
@Override
public void run() {
resultNameLabel.setText(media.getName() + " (" + media.getReleaseYear() + ")");
resultTypeLabel.setText(media.getType().toString());
resultTypeLabel.setText(media.getType().getName());
updateResults(1); // Get season 1 on search

// Only do this if media is a TV Series
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.zemahzalek.ratingreader;
package com.zemahzalek.ratingreader.controller;

import com.zemahzalek.ratingreader.model.Media;
import com.zemahzalek.ratingreader.model.MediaType;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Expand All @@ -20,7 +22,7 @@ public ImdbController(Media media) {
this.media = media;
}

void setMedia(String mediaName) throws IOException {
public void setMedia(String mediaName) throws IOException {
fetchImdbWebsiteCode(mediaName);
fetchMediaName();
fetchMediaType();
Expand Down Expand Up @@ -64,60 +66,43 @@ private void fetchSeasonsWebsiteCode() throws IOException {
}

private void fetchMediaName() {
if(mainWebsiteCode == null) {
return;
}

String name = mainWebsiteCode.getElementsByClass("title_wrapper").first().child(0).text();
media.setName(name);
}

private void fetchMediaType() {
if(mainWebsiteCode == null) {
return;
}

String type = mainWebsiteCode.getElementsByClass("subtext").first().select("a").last().text(); // Gets first "subtext" div and selects last element of type "a"
type = type.replaceAll("[^A-Za-z]", ""); // Remove all non alphabetic characters

// Sets correct mediaType
MediaType mediaType;
switch (type) {
case "Movie":
mediaType = MediaType.MOVIE;
break;

case "TVSeries":
mediaType = MediaType.SERIES;
break;

case "TVMiniSeries":
mediaType = MediaType.MINISERIES;
break;

default:
mediaType = MediaType.OTHER;
break;
if(type.equalsIgnoreCase("TVSeries")) {
mediaType = MediaType.SERIES;
}
else if(type.equalsIgnoreCase("TVMiniSeries")) {
mediaType = MediaType.MINISERIES;
}
else if(type.contains("Videogame")) {
mediaType = MediaType.VIDEOGAME;
}
else {
mediaType = MediaType.MOVIE;
}

media.setType(mediaType);
}

private void fetchMediaReleaseYear() {
if(mainWebsiteCode == null) {
String releaseYear = mainWebsiteCode.getElementsByClass("subtext").first().select("a").last().text(); // Gets first "subtext" div and selects last element of type "a"
releaseYear = releaseYear.replaceAll("[^\\d]", ""); // Remove all non numeric characters

// If no release year is found
if(releaseYear.equals("")) {
return;
}

String releaseYear = mainWebsiteCode.getElementsByClass("subtext").first().select("a").last().text(); // Gets first "subtext" div and selects last element of type "a"

char firstChar = releaseYear.charAt(0);
// Check if firstChar is a number
if(firstChar >= '0' && firstChar <= '9') {
releaseYear = releaseYear.replaceAll("[^\\d]", ""); // Remove all non numeric characters
if(releaseYear.length() > 4) {
releaseYear = releaseYear.substring(releaseYear.length() - 4); // Keeps only 4 last numbers (the year)
} else {
releaseYear = releaseYear.replaceAll("[^\\d]", ""); // Remove all non numeric characters
releaseYear = releaseYear.substring(0,4); // Cuts of excess year information
}

media.setReleaseYear(Integer.parseInt(releaseYear));
Expand All @@ -136,7 +121,6 @@ private void fetchMediaCategory() {
*/

private void fetchNrSeasons() {

String seasonsAndYearsDivName = "seasons-and-year-nav";
int seasonDivIndex = 3;
Element seasonsAndYearDiv = mainWebsiteCode.getElementsByClass(seasonsAndYearsDivName).first(); // Get first div of that name
Expand All @@ -146,7 +130,6 @@ private void fetchNrSeasons() {
}

private void fetchNrEpisodesPerSeason() {

ArrayList<Integer> episodeAmount = new ArrayList<>();
for (int i = 0; i < media.getNrSeasons(); i++) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.zemahzalek.ratingreader;
package com.zemahzalek.ratingreader.model;

import java.util.ArrayList;

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/zemahzalek/ratingreader/model/MediaType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.zemahzalek.ratingreader.model;

public enum MediaType {
MOVIE("Movie"), SERIES("Series"), MINISERIES("Miniseries"), VIDEOGAME("Video Game"), OTHER("Other");

private String name;

MediaType(String name) {
this.name = name;
}

public String getName() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zemahzalek.ratingreader;
package com.zemahzalek.ratingreader.view;

import com.zemahzalek.ratingreader.model.Media;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.zemahzalek.ratingreader;
package com.zemahzalek.ratingreader.view;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class RatingReader extends Application {

public static void run(String[] args) {
Expand All @@ -18,9 +22,18 @@ public void start(Stage stage) throws Exception {
Scene scene = new Scene(rootFXML, 700, 500);
stage.setMinWidth(650);
stage.setMinHeight(400);
stage.setTitle("Rating Reader 0.6.0");
String title = readPropertiesFile("dev.name") + " " + readPropertiesFile("dev.version");
stage.setTitle(title);

stage.setScene(scene);
stage.show();
}

private String readPropertiesFile(String key) throws IOException {
Properties properties = new Properties();
InputStream stream = this.getClass().getResourceAsStream("/dev.properties");
properties.load(stream);

return properties.getProperty(key);
}
}
4 changes: 4 additions & 0 deletions src/main/resources/dev.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dev.name = Rating Reader
dev.executable.name = RatingReader
dev.version = 0.6.3
dev.url = https://github.com/sam123bir/RatingReader
4 changes: 2 additions & 2 deletions src/main/resources/fxml/root.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.text.Font?>

<AnchorPane fx:id="rootAnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zemahzalek.ratingreader.Controller">
<AnchorPane fx:id="rootAnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="700.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zemahzalek.ratingreader.controller.Controller">
<children>
<TextField fx:id="searchTextField" layoutX="20.0" layoutY="22.0" prefHeight="30.0" prefWidth="200.0" />
<Button fx:id="searchButton" layoutX="234.0" layoutY="22.0" mnemonicParsing="false" onMousePressed="#onPressSearchButton" prefHeight="30.0" prefWidth="60.0" text="Search">
Expand All @@ -24,7 +24,7 @@
<Font size="15.0" />
</font>
</Label>
<ComboBox fx:id="seasonComboBox" layoutX="81.0" layoutY="62.0" prefHeight="30.0" prefWidth="53.0" />
<ComboBox fx:id="seasonComboBox" layoutX="81.0" layoutY="62.0" prefHeight="30.0" prefWidth="55.0" />
<Label fx:id="resultNameLabel" layoutX="350.0" layoutY="19.0" prefHeight="36.0" prefWidth="330.0" text="Name (year)" AnchorPane.leftAnchor="350.0" AnchorPane.rightAnchor="20.0">
<font>
<Font name="System Bold" size="25.0" />
Expand Down

0 comments on commit 4b73e8d

Please sign in to comment.