Skip to content

Commit

Permalink
Added support for Animeworld.tv (#1182)
Browse files Browse the repository at this point in the history
* Add Animeworld page support

* Add Animeworld player url

* Add Animeworld support

* Add Animeworld to supported pages

* Run linting tool

* Updated css for Animeworld.tv

* Fix in Animeworld.tv

Fix global require warning and Unexpected unnamed function warning

* Updated tests for Animeworld.tv

* Changed getEpisode selector

* Implemented getMalUrl

* Reverted back to master

* getMalUrl always return mal url if available

* Fix getMalUrl misunderstanding

getMalUrl always return mal url if available else checks the requested provider

* Fixed page match url

* Added 9anime-like active episode overview

* Fixed small bug when changing episode

* disable hex rule

* fix some things in animeworld

* narrow selector

* enable test

* fix overviewurl

* fix test

Co-authored-by: Henrik <22085664+henrik9999@users.noreply.github.com>
  • Loading branch information
n4y0n and henrik9999 committed Jul 12, 2022
1 parent 6c290b7 commit 1f0728e
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"selector-class-pattern": null,
"selector-id-pattern": null,
"number-max-precision": null,
"custom-property-empty-line-before": "never"
"custom-property-empty-line-before": "never",
"color-hex-length": null
}
}
92 changes: 92 additions & 0 deletions src/pages/Animeworld/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { pageInterface } from '../pageInterface';

export const Animeworld: pageInterface = {
name: 'Animeworld',
domain: 'https://www.animeworld.tv',
languages: ['Italian'],
type: 'anime',
isSyncPage(url) {
if (url.split('/')[4] !== undefined && url.split('/')[4].length) {
return true;
}
return false;
},
sync: {
getTitle(url) {
return j.$('#anime-title').text().trim();
},
getIdentifier(url) {
return utils.urlPart(url, 4);
},
getOverviewUrl(url) {
return utils.absoluteLink(
j.$('div.server:not([style*="display: none"]) a[href*="/play"]').first().attr('href'),
Animeworld.domain,
);
},
getMalUrl(provider) {
const malUrl = j.$('#mal-button').attr('href');
if (malUrl) {
return malUrl;
}

if (provider === 'ANILIST') {
return j.$('#anilist-button').attr('href') || false;
}

return false;
},
getEpisode(url) {
return parseInt(
j.$('div.server a[href*="/play"].active').first().attr('data-episode-num') || '1',
);
},
uiSelector(selector) {
j.$('div.widget.player')
.first()
.after(
j.html(
`<div id="mal-sync-ui-selector" class="widget crop text-center">${selector}</div>`,
),
);
},
},
overview: {
getTitle(url) {
return '';
},
getIdentifier(url) {
return '';
},
uiSelector(selector) {
// no ui
},
list: {
offsetHandler: false,
elementsSelector() {
return j.$('div.server a[href*="/play"]');
},
elementUrl(selector) {
return utils.absoluteLink(selector.attr('href'), Animeworld.domain);
},
elementEp(selector) {
return Number(selector.attr('data-episode-num'));
},
},
},
init(page) {
api.storage.addStyle(
// eslint-disable-next-line global-require
require('!to-string-loader!css-loader!less-loader!./style.less').toString(),
);
utils.fullUrlChangeDetect(() => {
page.reset();
j.$('#mal-sync-ui-selector').remove();
if (document.title.includes('Pagina non trovata')) {
con.error('404');
return;
}
page.handlePage();
});
},
};
5 changes: 5 additions & 0 deletions src/pages/Animeworld/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"urls": {
"match": ["*://*.animeworld.tv/play/*"]
}
}
28 changes: 28 additions & 0 deletions src/pages/Animeworld/style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@import './../pages';

@activeEp: #002966 !important;

.mal-sync-active {
color: #ffffff !important;
}

#malp {
padding: 0% 2%;
margin: 1%;
}

#malp * {
color: black;
select option {
color: black;
background-color: white;
}
}

body.dark #malp * {
color: white;
select option {
color: white;
background-color: black;
}
}
17 changes: 17 additions & 0 deletions src/pages/Animeworld/tests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"title": "animeworld",
"url": "https://www.animeworld.tv/",
"testCases": [
{
"url": "https://www.animeworld.tv/play/otome-game-sekai-wa-mob-ni-kibishii-sekai-desu.5z9UH/htfv9X",
"expected": {
"sync": true,
"title": "Otome Game Sekai wa Mob ni Kibishii Sekai desu",
"identifier": "otome-game-sekai-wa-mob-ni-kibishii-sekai-desu.5z9UH",
"overviewUrl": "https://www.animeworld.tv/play/otome-game-sekai-wa-mob-ni-kibishii-sekai-desu.5z9UH/htfv9X",
"episode": 1,
"uiSelector": true
}
}
]
}
2 changes: 2 additions & 0 deletions src/pages/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ import { Animetoast } from './Animetoast/main';
import { MuitoManga } from './MuitoManga/main';
import { RealmScans } from './RealmScans/main';
import { LuminousScans } from './LuminousScans/main';
import { Animeworld } from './Animeworld/main';

export const pages = {
nineAnime,
Expand Down Expand Up @@ -272,4 +273,5 @@ export const pages = {
MuitoManga,
RealmScans,
LuminousScans,
Animeworld,
};
4 changes: 4 additions & 0 deletions src/pages/playerUrls.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,4 +725,8 @@ module.exports = {
simplyaweeb: {
match: ['*://player.simplyaweeb.to/*'],
},
// animeworld
animeworld: {
match: ['*://www.animeworld.tv/api/episode/serverPlayerAnimeWorld?id=*'],
},
};

0 comments on commit 1f0728e

Please sign in to comment.