Skip to content

Commit 658a30d

Browse files
committed
Update youtube connector
Don't return unique ID if chapters are available. Otherwise the same ID will be used for different tracks.
1 parent fcd1748 commit 658a30d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/connectors/youtube.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Connector.getTrackInfo = () => {
6161

6262
Connector.getTimeInfo = () => {
6363
const videoElement = document.querySelector(videoSelector);
64-
if (videoElement && areChaptersMissing()) {
64+
if (videoElement && !areChaptersAvailable()) {
6565
const { currentTime, duration } = videoElement;
6666

6767
return { currentTime, duration };
@@ -75,6 +75,10 @@ Connector.isPlaying = () => {
7575
};
7676

7777
Connector.getUniqueID = () => {
78+
if (areChaptersAvailable()) {
79+
return null;
80+
}
81+
7882
/*
7983
* ytd-watch-flexy element contains ID of a first played video
8084
* if the miniplayer is visible, so we should check
@@ -122,8 +126,8 @@ function setupEventListener() {
122126
$(videoSelector).on('timeupdate', Connector.onStateChanged);
123127
}
124128

125-
function areChaptersMissing() {
126-
return !Util.getTextFromSelectors(chapterNameSelector);
129+
function areChaptersAvailable() {
130+
return Util.getTextFromSelectors(chapterNameSelector);
127131
}
128132

129133
/**

0 commit comments

Comments
 (0)