From bc9111075f197dceb4d83b0ac39b5ec62dd2497b Mon Sep 17 00:00:00 2001 From: Tim Meier Date: Fri, 6 Jan 2017 15:30:38 +0100 Subject: [PATCH] Change tv tv_title to name (#24) --- .../app/fixtures/fixturesMoviesSnapshot.js | 7 ------- .../app/fixtures/fixturesResultFetch.js | 16 ++++++++-------- .../app/fixtures/fixturesTvSnapshot.js | 11 ----------- flox-file-parser/app/index.spec.js | 12 ++++++------ flox-file-parser/app/lib/parser.js | 9 ++------- flox-file-parser/app/lib/parser.tv.js | 1 - flox-file-parser/app/lib/parser.tv.spec.js | 4 ++-- .../migrations/20170106141138-remove-tv_title.js | 11 +++++++++++ flox-file-parser/database/models/file_history.js | 1 - 9 files changed, 29 insertions(+), 43 deletions(-) create mode 100644 flox-file-parser/database/migrations/20170106141138-remove-tv_title.js diff --git a/flox-file-parser/app/fixtures/fixturesMoviesSnapshot.js b/flox-file-parser/app/fixtures/fixturesMoviesSnapshot.js index 3673fc2..15a7435 100644 --- a/flox-file-parser/app/fixtures/fixturesMoviesSnapshot.js +++ b/flox-file-parser/app/fixtures/fixturesMoviesSnapshot.js @@ -13,7 +13,6 @@ module.exports = [ "tags" : "hd,1080p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : null }, { @@ -30,7 +29,6 @@ module.exports = [ "tags" : "720p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt" }, { @@ -47,7 +45,6 @@ module.exports = [ "tags" : "hd,1080p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : null }, { @@ -64,7 +61,6 @@ module.exports = [ "tags" : "hd,1080p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : null }, { @@ -81,7 +77,6 @@ module.exports = [ "tags" : "720p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : __dirname + "/movies/subfolder/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt" }, { @@ -98,7 +93,6 @@ module.exports = [ "tags" : "hd,1080p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : null }, { @@ -115,7 +109,6 @@ module.exports = [ "tags" : "720p", "episode_number" : null, "season_number" : null, - "tv_title" : null, "subtitles" : __dirname + "/movies/Warcraft.2016.720p.WEB-DL/Warcraft.2016.720p.WEB-DL.srt" } ] diff --git a/flox-file-parser/app/fixtures/fixturesResultFetch.js b/flox-file-parser/app/fixtures/fixturesResultFetch.js index 274921b..e8cea5d 100644 --- a/flox-file-parser/app/fixtures/fixturesResultFetch.js +++ b/flox-file-parser/app/fixtures/fixturesResultFetch.js @@ -1,7 +1,7 @@ var fetch = module.exports.fetch = { "tv": [ { - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "season_number": 1, "episode_number": 1, "extension": "mkv", @@ -13,7 +13,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Breaking Bad/S1/1.mkv" }, { - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "season_number": 1, "episode_number": 2, "extension": "mkv", @@ -25,7 +25,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Breaking Bad/S1/2.mkv" }, { - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "season_number": 2, "episode_number": 1, "status": "added", @@ -37,7 +37,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Breaking Bad/s2/1.mp4" }, { - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "season_number": 2, "episode_number": 2, "tags": [], @@ -49,7 +49,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Breaking Bad/s2/2.mkv" }, { - "tv_title": "Game of Thrones", + "name": "Game of Thrones", "season_number": 2, "episode_number": 1, "status": "added", @@ -61,7 +61,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Game of Thrones/S2/1.mkv" }, { - "tv_title": "Game of Thrones", + "name": "Game of Thrones", "season_number": 2, "episode_number": 2, "tags": [], @@ -73,7 +73,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Game of Thrones/S2/2.mkv" }, { - "tv_title": "Game of Thrones", + "name": "Game of Thrones", "season_number": 1, "episode_number": 1, "extension": "mkv", @@ -85,7 +85,7 @@ var fetch = module.exports.fetch = { "src": __dirname + "/tv/Game of Thrones/s1/1.mkv" }, { - "tv_title": "Game of Thrones", + "name": "Game of Thrones", "season_number": 1, "tags": [], "episode_number": 2, diff --git a/flox-file-parser/app/fixtures/fixturesTvSnapshot.js b/flox-file-parser/app/fixtures/fixturesTvSnapshot.js index c7c0b8f..676d7b0 100644 --- a/flox-file-parser/app/fixtures/fixturesTvSnapshot.js +++ b/flox-file-parser/app/fixtures/fixturesTvSnapshot.js @@ -13,7 +13,6 @@ module.exports = [ "tags" : null, "episode_number" : 1, "season_number" : 1, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt" }, { @@ -30,7 +29,6 @@ module.exports = [ "tags" : null, "episode_number" : 2, "season_number" : 1, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/S1/2.srt" }, { @@ -47,7 +45,6 @@ module.exports = [ "tags" : null, "episode_number" : 1, "season_number" : 2, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/s2/1.srt" }, { @@ -64,7 +61,6 @@ module.exports = [ "tags" : null, "episode_number" : 2, "season_number" : 2, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/s2/2.srt" }, { @@ -81,7 +77,6 @@ module.exports = [ "tags" : null, "episode_number" : 1, "season_number" : 2, - "tv_title" : "Game of Thrones", "subtitles" : null }, { @@ -98,7 +93,6 @@ module.exports = [ "tags" : null, "episode_number" : 2, "season_number" : 2, - "tv_title" : "Game of Thrones", "subtitles" : null }, { @@ -115,7 +109,6 @@ module.exports = [ "tags" : null, "episode_number" : 1, "season_number" : 1, - "tv_title" : "Game of Thrones", "subtitles" : null }, { @@ -132,7 +125,6 @@ module.exports = [ "tags" : null, "episode_number" : 2, "season_number" : 1, - "tv_title" : "Game of Thrones", "subtitles" : null }, { @@ -149,7 +141,6 @@ module.exports = [ "tags" : null, "episode_number" : 1, "season_number" : 1, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt" }, { @@ -166,7 +157,6 @@ module.exports = [ "tags" : null, "episode_number" : 1, "season_number" : 1, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/S1/1.srt" }, { @@ -183,7 +173,6 @@ module.exports = [ "tags" : null, "episode_number" : 2, "season_number" : 2, - "tv_title" : "Breaking Bad", "subtitles" : __dirname + "/tv/Breaking Bad/s2/2.srt" } ] diff --git a/flox-file-parser/app/index.spec.js b/flox-file-parser/app/index.spec.js index 9c30ea0..7cd7ca8 100644 --- a/flox-file-parser/app/index.spec.js +++ b/flox-file-parser/app/index.spec.js @@ -471,7 +471,7 @@ describe("HTTP Server", () => { "src": __dirname + "/fixtures/tv/Breaking Bad/S1/1.mp4", "status": "added", "season_number": 1, - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "year": null, "tags": [], "filename": "1" @@ -483,7 +483,7 @@ describe("HTTP Server", () => { "src": __dirname + "/fixtures/tv/Breaking Bad/S1/1.mkv", "status": "removed", "season_number": 1, - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "year": null, "tags": [], "filename": "1" @@ -495,7 +495,7 @@ describe("HTTP Server", () => { "src": __dirname + "/fixtures/tv/Breaking Bad/S1/1.mkv", "status": "added", "season_number": 1, - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "year": null, "tags": [], "filename": "1" @@ -507,7 +507,7 @@ describe("HTTP Server", () => { "src": __dirname + "/fixtures/tv/Breaking Bad/S1/1.mp4", "status": "removed", "season_number": 1, - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "year": null, "tags": [], "filename": "1" @@ -519,7 +519,7 @@ describe("HTTP Server", () => { "src": __dirname + "/fixtures/tv/Breaking Bad/s2/2.mkv", "status": "removed", "season_number": 2, - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "year": null, "tags": [], "filename": "2" @@ -531,7 +531,7 @@ describe("HTTP Server", () => { "src": __dirname + "/fixtures/tv/Breaking Bad/s2/2.mkv", "status": "added", "season_number": 2, - "tv_title": "Breaking Bad", + "name": "Breaking Bad", "year": null, "tags": [], "filename": "2" diff --git a/flox-file-parser/app/lib/parser.js b/flox-file-parser/app/lib/parser.js index 8092d1d..f6aabad 100644 --- a/flox-file-parser/app/lib/parser.js +++ b/flox-file-parser/app/lib/parser.js @@ -13,6 +13,7 @@ const append = (model, status) => { src: model.src, date: date, status: status, + name: model.name, year: model.year, tags: model.tags ? model.tags.split(",") : [], filename: model.filename @@ -21,16 +22,10 @@ const append = (model, status) => { if(model.category === "tv") { Object.assign(base, { episode_number: model.episode_number, - season_number: model.season_number, - tv_title: model.tv_title + season_number: model.season_number }) } - if(model.category === "movies") { - Object.assign(base, { - name: model.name - }) - } return base } diff --git a/flox-file-parser/app/lib/parser.tv.js b/flox-file-parser/app/lib/parser.tv.js index b1d92ca..3d4409a 100644 --- a/flox-file-parser/app/lib/parser.tv.js +++ b/flox-file-parser/app/lib/parser.tv.js @@ -45,7 +45,6 @@ const addEpisode = (episodesPath, episodeName, promises, season_number, tv_title name: tv_title, episode_number: helper.normalizeNumber(episodeName), season_number: season_number, - tv_title: tv_title, src: absolutePathEpisode } })) diff --git a/flox-file-parser/app/lib/parser.tv.spec.js b/flox-file-parser/app/lib/parser.tv.spec.js index 2c82118..67f7c5f 100644 --- a/flox-file-parser/app/lib/parser.tv.spec.js +++ b/flox-file-parser/app/lib/parser.tv.spec.js @@ -87,8 +87,8 @@ describe("Parser (tv)", () => { result = parser.fetch() return result.tv.then((res) => { - got = res.filter((t) => t.tv_title === game_of_thrones) - bb = res.filter((t) => t.tv_title === breaking_bad) + got = res.filter((t) => t.name === game_of_thrones) + bb = res.filter((t) => t.name === breaking_bad) got_s1 = got.filter((e) => e.season_number === 1) got_s2 = got.filter((e) => e.season_number === 2) diff --git a/flox-file-parser/database/migrations/20170106141138-remove-tv_title.js b/flox-file-parser/database/migrations/20170106141138-remove-tv_title.js new file mode 100644 index 0000000..fb2a09e --- /dev/null +++ b/flox-file-parser/database/migrations/20170106141138-remove-tv_title.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.removeColumn("file_histories", "tv_title") + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.addColumn("file_histories", "tv_title", Sequelize.STRING, { allowNull: true }) + } +}; diff --git a/flox-file-parser/database/models/file_history.js b/flox-file-parser/database/models/file_history.js index f603479..d17e8f2 100644 --- a/flox-file-parser/database/models/file_history.js +++ b/flox-file-parser/database/models/file_history.js @@ -10,7 +10,6 @@ module.exports = function(sequelize, DataTypes) { tags: DataTypes.TEXT, episode_number: DataTypes.INTEGER, season_number: DataTypes.INTEGER, - tv_title: DataTypes.TEXT, subtitles: DataTypes.TEXT, createdAt: DataTypes.DATE, updatedAt: DataTypes.DATE,