Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MylistPocket: マイリストを操作できない #6

Open
kphrx opened this issue Oct 3, 2021 · 3 comments
Open

MylistPocket: マイリストを操作できない #6

kphrx opened this issue Oct 3, 2021 · 3 comments
Assignees
Labels

Comments

@kphrx
Copy link
Owner

kphrx commented Oct 3, 2021

www.nicovideo.jp/mylist_add/video/${watchId} が消えてるのでMylistPocketが使えない

ZenzaWatchで使ってるマイリスト関連APIから使えるやつ並べておく

あとで見る(とりあえずマイリスト) API endpoint
nvapi.nicovideo.jp
POST /v1/users/me/deflist/items/${watchId}
POST /v1/users/me/watch-later body: watchId=${watchId}&memo=${memo}

マイリスト API endpoint
nvapi.nicovideo.jp
POST /v1/users/me/mylists/${mylistId}/items?itemId=${itemId:watchId}&description=${memo}

@kphrx
Copy link
Owner Author

kphrx commented Oct 3, 2021

ニコニコ大百科の掲示板での報告: 1493, 1495, 1500

@kphrx
Copy link
Owner Author

kphrx commented Oct 15, 2021

DeflistApiLoader._addItem/4

ZenzaWatch/src/_pocket.js

Lines 2418 to 2497 in 7687a7a

static __addItem({watchId, description, token, isRetry = false}) {
const cacheKey = 'deflistItems';
const url = 'https://www.nicovideo.jp/api/deflist/add';
let body = 'item_id=' + watchId + '&token=' + token;
if (description) {
body += '&description='+ encodeURIComponent(description);
}
const req = {
method: 'post',
credentials: 'include',
body,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
};
return new Promise((resolve, reject) => {
fetch(url, req)
.then((res) => { return res.json(); })
.then((result) => {
if (result.status && result.status === 'ok') {
cacheStorage.removeItem(cacheKey);
//ZenzaWatch.emitter.emitAsync('deflistAdd', watchId, description);
return resolve({
status: 'ok',
result: result,
message: 'とりあえずマイリスト登録'
});
}
if (!result.status || !result.error) {
return reject({
status: 'fail',
result: result,
message: 'とりあえずマイリスト登録失敗(100)'
});
}
if (result.error.code !== 'EXIST' || isRetry) {
return reject({
status: 'fail',
result: result,
code: result.error.code,
message: result.error.description
});
}
/**
* すでに登録されている場合は、いったん削除して再度追加(先頭に移動)
*/
return DeflistApiLoader.removeItem(watchId)
.then(util.getSleepPromise(1500, 'deflist remove'))
.then(() => {
return DeflistApiLoader._addItem(watchId, description, true)
.then((result) => {
resolve({
status: 'ok',
result: result,
message: 'とりあえずマイリストの先頭に移動'
});
});
}, (err) => {
reject({
status: 'fail',
result: err.result,
code: err.code,
message: 'とりあえずマイリスト登録失敗(101)'
});
});
}, (err) => {
reject({
status: 'fail',
result: err,
message: 'とりあえずマイリスト登録失敗(200)'
});
});
});
}

mylist-window command

ZenzaWatch/src/_pocket.js

Lines 3548 to 3553 in 7687a7a

case 'mylist-window':
window.open(
protocol + '//www.nicovideo.jp/mylist_add/video/' + param,
'nicomylistadd',
'width=500, height=400, menubar=no, scrollbars=no');
break;

@kphrx
Copy link
Owner Author

kphrx commented Oct 24, 2021

MylistApiLoaderをMylistPocketで使うようにしたから任意のマイリストに追加する機能はUI作れば良い

@kphrx kphrx self-assigned this Oct 24, 2021
@kphrx kphrx added the bug label Oct 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant