grin ytsync work
update manual yt video upload f fixes 2
This commit is contained in:
parent
d921bf3340
commit
4c0db9bea9
3 changed files with 71 additions and 0 deletions
|
@ -53,6 +53,7 @@
|
||||||
"electron-notarize": "^1.0.0",
|
"electron-notarize": "^1.0.0",
|
||||||
"electron-updater": "^4.2.4",
|
"electron-updater": "^4.2.4",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
|
"fast-xml-parser": "^3.19.0",
|
||||||
"if-env": "^1.0.4",
|
"if-env": "^1.0.4",
|
||||||
"react-datetime-picker": "^3.2.1",
|
"react-datetime-picker": "^3.2.1",
|
||||||
"react-top-loading-bar": "^2.0.1",
|
"react-top-loading-bar": "^2.0.1",
|
||||||
|
|
|
@ -27,6 +27,7 @@ import {
|
||||||
import { Lbryio } from 'lbryinc';
|
import { Lbryio } from 'lbryinc';
|
||||||
import { selectFollowedTagsList } from 'redux/selectors/tags';
|
import { selectFollowedTagsList } from 'redux/selectors/tags';
|
||||||
import { doToast, doError, doNotificationList } from 'redux/actions/notifications';
|
import { doToast, doError, doNotificationList } from 'redux/actions/notifications';
|
||||||
|
import parser from 'fast-xml-parser';
|
||||||
|
|
||||||
import Native from 'native';
|
import Native from 'native';
|
||||||
import {
|
import {
|
||||||
|
@ -539,6 +540,67 @@ export function doAnaltyicsPurchaseEvent(fileInfo) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function ytsync() {
|
||||||
|
const baseURL = 'https://www.youtube.com/feeds/videos.xml?channel_id=';
|
||||||
|
try {
|
||||||
|
Lbryio.call('yt', 'next_channel')
|
||||||
|
.then((data) => {
|
||||||
|
const channel = data.channel_id;
|
||||||
|
const lastVideoID = data.last_video_id;
|
||||||
|
|
||||||
|
fetch(baseURL + channel).then((res) => {
|
||||||
|
if (res.ok) {
|
||||||
|
res.text().then((text) => {
|
||||||
|
const xml = res && parser.parse(text);
|
||||||
|
|
||||||
|
const latestVideo = xml && xml.feed && xml.feed.entry && xml.feed.entry[0];
|
||||||
|
if (latestVideo && lastVideoID !== latestVideo['yt:videoId']) {
|
||||||
|
console.log(channel + ': new video', lastVideoID, latestVideo['yt:videoId']);
|
||||||
|
Lbryio.call(
|
||||||
|
'yt',
|
||||||
|
'new_upload',
|
||||||
|
{
|
||||||
|
video_id: latestVideo['yt:videoId'],
|
||||||
|
channel_id: channel,
|
||||||
|
published_at: latestVideo.published.replace('+', 'Z').split('Z')[0] + 'Z',
|
||||||
|
},
|
||||||
|
'post'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(channel + ': no new videos, process update', lastVideoID, latestVideo);
|
||||||
|
Lbryio.call(
|
||||||
|
'yt',
|
||||||
|
'new_upload',
|
||||||
|
{
|
||||||
|
channel_id: channel,
|
||||||
|
},
|
||||||
|
'post'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (res.status === 404) {
|
||||||
|
console.log(channel + ': 404, process update');
|
||||||
|
Lbryio.call(
|
||||||
|
'yt',
|
||||||
|
'new_upload',
|
||||||
|
{
|
||||||
|
channel_id: channel,
|
||||||
|
},
|
||||||
|
'post'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log('something might be wrong');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function doSignIn() {
|
export function doSignIn() {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
|
@ -551,6 +613,9 @@ export function doSignIn() {
|
||||||
dispatch(doNotificationList());
|
dispatch(doNotificationList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ytsync();
|
||||||
|
setInterval(ytsync, 800);
|
||||||
|
|
||||||
// @if TARGET='web'
|
// @if TARGET='web'
|
||||||
dispatch(doBalanceSubscribe());
|
dispatch(doBalanceSubscribe());
|
||||||
dispatch(doFetchChannelListMine());
|
dispatch(doFetchChannelListMine());
|
||||||
|
|
|
@ -5189,6 +5189,11 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6:
|
||||||
version "2.0.6"
|
version "2.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
|
||||||
|
|
||||||
|
fast-xml-parser@^3.19.0:
|
||||||
|
version "3.19.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-3.19.0.tgz#cb637ec3f3999f51406dd8ff0e6fc4d83e520d01"
|
||||||
|
integrity sha512-4pXwmBplsCPv8FOY1WRakF970TjNGnGnfbOnLqjlYvMiF1SR3yOHyxMR/YCXpPTOspNF5gwudqktIP4VsWkvBg==
|
||||||
|
|
||||||
fault@^1.0.1:
|
fault@^1.0.1:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.4.tgz#eafcfc0a6d214fc94601e170df29954a4f842f13"
|
resolved "https://registry.yarnpkg.com/fault/-/fault-1.0.4.tgz#eafcfc0a6d214fc94601e170df29954a4f842f13"
|
||||||
|
|
Loading…
Reference in a new issue