Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
feat: Update plot field + fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunal Nagar committed Jul 2, 2021
1 parent 0faf40d commit a564bb6
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 60 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
"@semantic-release/github": "7.2.3",
"@semantic-release/npm": "7.1.3",
"@semantic-release/release-notes-generator": "9.0.3",
"@types/chai": "^4.2.19",
"@types/cors": "2.8.10",
"@types/express": "4.17.12",
"@types/mocha": "^8.2.2",
"@types/node-fetch": "2.5.10",
"@types/underscore": "1.11.2",
"@typescript-eslint/eslint-plugin": "4.28.1",
Expand Down
3 changes: 1 addition & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
export const constants = {
IMDB: {
BASE: 'https://www.imdb.com',
LIST:
'https://www.imdb.com/list/<listID>/?sort=date_added,desc&st_dt=&mode=detail&page=<pageNumber>',
LIST: 'https://www.imdb.com/list/<listID>/?sort=date_added,desc&st_dt=&mode=detail&page=<pageNumber>',
PERSON: 'https://www.imdb.com/name/<nameID>',
TITLE: 'https://www.imdb.com/title/<titleID>',
WATCHLIST:
Expand Down
32 changes: 16 additions & 16 deletions src/models/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ export interface IBase {
}

export default class Base {
protected _baseUrl: string;
protected _id: string;
protected _description: string;
protected _name: string;
protected _type: string;
protected _link: string;
protected _img: string;
protected _keywords: string;
protected baseUrl: string;
protected id: string;
protected description: string;
protected name: string;
protected type: string;
protected link: string;
protected img: string;
protected keywords: string;

constructor(config: IBase) {
this._baseUrl = constants.IMDB.BASE;
this._id = config.id;
this._description = config.description;
this._name = config.name;
this._type = config.type;
this._link = config.link;
this._img = config.img;
this._keywords = config.keywords;
this.baseUrl = constants.IMDB.BASE;
this.id = config.id;
this.description = config.description;
this.name = config.name;
this.type = config.type;
this.link = config.link;
this.img = config.img;
this.keywords = config.keywords;
}
}
60 changes: 30 additions & 30 deletions src/models/movie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ export interface IMovie extends IBase {
}

export default class Movie extends Base {
protected _year: string;
protected _plot: string;
protected _storyline: string;
protected _certificate: string;
protected _rating: number;
protected _votes: number;
protected _movieMeterCurrentRank: string;
protected _runtime: string;
protected _release: string;
protected _metascore: string;
protected _trailer: string;
protected _genres: string;
protected _stars: string;
protected _directors: string;
protected _creators: string;
protected year: string;
protected plot: string;
protected storyline: string;
protected certificate: string;
protected rating: number;
protected votes: number;
protected movieMeterCurrentRank: string;
protected runtime: string;
protected release: string;
protected metascore: string;
protected trailer: string;
protected genres: string;
protected stars: string;
protected directors: string;
protected creators: string;

constructor(config: IMovie) {
super(config);
this._year = config.year;
this._plot = config.plot;
this._storyline = config.storyline;
this._certificate = config.certificate;
this._rating = config.rating;
this._votes = config.votes;
this._movieMeterCurrentRank = config.movieMeterCurrentRank;
this._runtime = config.runtime;
this._release = config.release;
this._metascore = config.metascore;
this._trailer = config.trailer;
this._genres = config.genres;
this._stars = config.stars;
this._directors = config.directors;
this._creators = config.creators;
this.year = config.year;
this.plot = config.plot;
this.storyline = config.storyline;
this.certificate = config.certificate;
this.rating = config.rating;
this.votes = config.votes;
this.movieMeterCurrentRank = config.movieMeterCurrentRank;
this.runtime = config.runtime;
this.release = config.release;
this.metascore = config.metascore;
this.trailer = config.trailer;
this.genres = config.genres;
this.stars = config.stars;
this.directors = config.directors;
this.creators = config.creators;
}

buildGenre(genre: string): { link: string; name: string } {
Expand Down
22 changes: 11 additions & 11 deletions src/models/person.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ export interface IPerson extends IBase {
}

export default class Person extends Base {
protected _born: string;
protected _hometown: string;
protected _jobTitles: string;
protected _height: string;
protected _filmography: string;
protected born: string;
protected hometown: string;
protected jobTitles: string;
protected height: string;
protected filmography: string;

constructor(config: IPerson) {
super(config);
this._born = config.born;
this._hometown = config.hometown;
this._jobTitles = config.jobTitles;
this._height = config.height;
this._filmography = config.filmography;
this.born = config.born;
this.hometown = config.hometown;
this.jobTitles = config.jobTitles;
this.height = config.height;
this.filmography = config.filmography;
this.setLink();
}

setLink(): void {
this._link = `/name/${this._id}`;
this.link = `/name/${this.id}`;
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/scraper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ export const getList = async (listID: string, page: string): Promise<void> => {
});
}

const summary = $that.find('.ratings-metascore + p').text().trim();
const summary = $that
.find('.ipl-rating-widget')
.nextAll('p')
.first()
.text()
.trim();
const directors: any = [];
$($p.get(2))
.children()
Expand Down
5 changes: 5 additions & 0 deletions tests/scraper.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@ describe('/GET /list/:listID/:page', () => {
expect(body.user.id).to.equal(constants.TEST.USER_ID);
expect(body.user.name).to.equal('iwantmoarcookiez');
expect(body.public).to.be.true;
expect(body.titles[0]).to.haveOwnProperty('id');
expect(body.titles[0]).to.haveOwnProperty('name');
expect(body.titles[0]).to.haveOwnProperty('link');
expect(body.titles[0]).to.haveOwnProperty('year');
expect(body.titles[0]).to.haveOwnProperty('plot');
});
});
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@
"@types/connect" "*"
"@types/node" "*"

"@types/chai@^4.2.19":
version "4.2.19"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.2.19.tgz#80f286b515897413c7a35bdda069cc80f2344233"
integrity sha512-jRJgpRBuY+7izT7/WNXP/LsMO9YonsstuL+xuvycDyESpoDoIAsMd7suwpB4h9oEWB+ZlPTqJJ8EHomzNhwTPQ==

"@types/connect@*":
version "3.4.34"
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.34.tgz#170a40223a6d666006d93ca128af2beb1d9b1901"
Expand Down Expand Up @@ -514,6 +519,11 @@
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256"
integrity sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg==

"@types/mocha@^8.2.2":
version "8.2.2"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-8.2.2.tgz#91daa226eb8c2ff261e6a8cbf8c7304641e095e0"
integrity sha512-Lwh0lzzqT5Pqh6z61P3c3P5nm6fzQK/MMHl9UKeneAeInVflBSz1O2EkX6gM6xfJd7FBXBY5purtLx7fUiZ7Hw==

"@types/node-fetch@2.5.10":
version "2.5.10"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.10.tgz#9b4d4a0425562f9fcea70b12cb3fcdd946ca8132"
Expand Down

0 comments on commit a564bb6

Please sign in to comment.