Skip to content

Commit

Permalink
Remove non-existant rewatch value from load; update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gilmoreg committed Jan 6, 2019
1 parent 05bfcb2 commit 9199d1c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 46 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
## Disclaimer
Use this script at your own risk! The author assumes no responsibility for any damages of any kind. It is *strongly* recommended you test this out on a throwaway MAL account before attempting to sync your main account.

## WARNING
Using this script will override certain advanced settings for MAL entries:
1. **Storage** will be cleared
2. **Rewatch/Re-read Value** will be cleared (not the number of rewatches, but your "rewatchability" setting from Low to Very High)
3. **Ask to Discuss?** will be set to: *Don't ask to discuss*
4. **Post to SNS** will be set to: *Follow default setting*

**Do not use this script if you care about those settings.** See details under Notes.

## About
So you're an Anilist user (perhaps you came over after MAL melted down) but you still want to keep your MAL page up to date for all your friends who still use it. Douki can sync your Anilist lists to MAL with the click of a button.

Expand All @@ -21,15 +12,16 @@ Unfortunately, given that MAL shut down its public API over security concerns, t
1. Install a userscript manager ([choose one from this list](https://greasyfork.org/en))
2. Install the script [here](https://greasyfork.org/en/scripts/373467-douki)
3. Visit [the import page on Myanimelist.net](https://myanimelist.net/import.php). *You need to be logged in to MAL.*
4. Alternatively, a link to the import page is added to the List dropdown at the top of the main page
5. Fill in your Anilist username and hit `Import`
4. Ensure the date setting matches your setting on MAL (US or Euro)
5. Alternatively, a link to the import page is added to the List dropdown at the top of the main page
6. Fill in your Anilist username and hit `Import`

## Notes
- The most common source of errors are titles that are not yet approved on Myanimelist. These cannot be added even manually. **Before reporting errors, check to see if you can add an item manually. If you can't add it, neither can Douki.**
- All custom scoring formats on Anilist (1-5, 1-100, stars) will be converted to MAL's 1-10 system. The scores will round down (i.e. a 95 will become a 9). This follows an established community practice.
- Custom lists will be imported into the main MAL list.
- Private lists will be ignored.
- Tags and notes will be ignored. Keeping these consistent across the two sites is too difficult for now. I am open to attempting this in the future, but no promises.
- The reason certain advanced settings have to be overwritten is that this data must be supplied when editing an entry, but due to limitations with how MAL works there is no practical way for the script to know what you have those set to. In lieu of this, defaults have been chosen. Feedback on the choices is welcome. "Storage" is the one which *might* be possible to implement, but it would be a huge effort and I doubt many people use this setting. Let me know if it is important to you.
- Due to a quirk with MAL's site, changing the number of times you've rewatched a show or reread a manga alone will not trigger an update. You need to also change status, episode/chapter count, or score for the script to pick up on a change and update the entry.

Please report issues [on the Anilist forum thread](https://anilist.co/forum/thread/2654). All suggestions, feedback, or bug reports are welcome.
8 changes: 8 additions & 0 deletions __tests__/MALEntry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ import * as fakes from '../__testutils__/testData';
const fakeDomMethods = fakes.createFakeDomMethods();

describe('shouldUpdate()', () => {
it('should not update if data is the same', () => {
const malAnime = fakes.createFakeMALAnime();
const alAnime = fakes.createFakeAnilistAnime();
const malEntry = new MALEntryAnime(alAnime, malAnime, 'csrfToken', fakeDomMethods);
const result = malEntry.shouldUpdate();
expect(result).toEqual(false);
});

it('should update if the start date is different', () => {
const malAnime = fakes.createFakeMALAnime({ start_date_string: '2-2-2002' });
const alAnime = fakes.createFakeAnilistAnime({ startedAt: { year: 2002, month: 1, day: 1 } });
Expand Down
2 changes: 0 additions & 2 deletions __testutils__/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const malItem: Types.BaseMALItem = {
const malAnime = {
...malItem,
anime_id: 1,
num_watched_times: 1,
num_watched_episodes: 12,
anime_airing_status: 2,
anime_num_episodes: 12,
Expand All @@ -24,7 +23,6 @@ const malManga = {
...malItem,
manga_id: 2,
num_read_chapters: 12,
num_read_times: 1,
num_read_volumes: 1
} as Types.MALLoadManga;

Expand Down
26 changes: 9 additions & 17 deletions douki.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,9 @@ class BaseMALEntry {
case 'csrf_token':
case 'anime_id':
case 'manga_id':
// This data is not part of the load.json list and so can't be used as update test
case 'num_watched_times':
case 'num_read_times':
return false;
case 'start_date':
case 'finish_date':
Expand Down Expand Up @@ -788,20 +791,6 @@ class BaseMALEntry {
;
return false;
}
// In certain cases the next two values will be missing from the MAL data and trying to update them will do nothing.
// To avoid a meaningless update every time, skip it if undefined on MAL
case 'num_watched_times':
case 'num_read_times':
{
if (!this.malData.hasOwnProperty(key)) {
return false;
}
if (this._postData[key] !== this.malData[key]) {
return true;
}
;
return false;
}
default:
{
// Treat falsy values as equivalent (!= doesn't do the trick here)
Expand Down Expand Up @@ -852,7 +841,8 @@ class MALEntryAnime extends BaseMALEntry {
// For new items it will not be present; however the list will refresh after add and
// it should be available then
result.num_watched_episodes = this.malData && this.malData.anime_num_episodes ?
Math.min(this.alData.progress, this.malData.anime_num_episodes) : 0;
Math.min(this.alData.progress, this.malData.anime_num_episodes) :
this.alData.progress || 0;
return result;
}
async formData() {
Expand Down Expand Up @@ -903,9 +893,11 @@ class MALEntryManga extends BaseMALEntry {
// For new items they will not be present; however the list will refresh after add and
// they should be available then
result.num_read_chapters = this.malData && this.malData.manga_num_chapters ?
Math.min(this.alData.progress, this.malData.manga_num_chapters) : 0;
Math.min(this.alData.progress, this.malData.manga_num_chapters) :
this.alData.progress || 0;
result.num_read_volumes = this.malData && this.malData.manga_num_volumes ?
Math.min(this.alData.progressVolumes, this.malData.manga_num_volumes) : 0;
Math.min(this.alData.progressVolumes, this.malData.manga_num_volumes) :
this.alData.progressVolumes || 0;
return result;
}
async formData() {
Expand Down
16 changes: 3 additions & 13 deletions src/MALEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ export class BaseMALEntry implements MALEntry {
case 'csrf_token':
case 'anime_id':
case 'manga_id':
// This data is not part of the load.json list and so can't be used as update test
case 'num_watched_times':
case 'num_read_times':
return false;
case 'start_date':
case 'finish_date':
Expand Down Expand Up @@ -137,19 +140,6 @@ export class BaseMALEntry implements MALEntry {
};
return false;
}
// In certain cases the next two values will be missing from the MAL data and trying to update them will do nothing.
// To avoid a meaningless update every time, skip it if undefined on MAL
case 'num_watched_times':
case 'num_read_times':
{
if (!this.malData.hasOwnProperty(key)) {
return false;
}
if (this._postData[key] !== this.malData[key]) {
return true;
};
return false;
}
default:
{
// Treat falsy values as equivalent (!= doesn't do the trick here)
Expand Down
2 changes: 0 additions & 2 deletions src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,13 @@ export interface BaseMALLoadItem extends BaseMALItem {

export interface MALLoadAnime extends BaseMALLoadItem {
anime_id: number
num_watched_times: number
num_watched_episodes: number
anime_num_episodes: number
anime_airing_status: number
}

export interface MALLoadManga extends BaseMALLoadItem {
manga_id: number
num_read_times: number
num_read_chapters: number
num_read_volumes: number
manga_num_chapters: number
Expand Down

0 comments on commit 9199d1c

Please sign in to comment.