Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Dailymotion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VideoStreaming
Plugins
Dailymotion
Commits
15bed353
Commit
15bed353
authored
9 months ago
by
Stefan Cruz
Browse files
Options
Downloads
Patches
Plain Diff
refact: refact getPlaylistsByUsername so it can later be reused
parent
a4195a60
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/DailymotionScript.ts
+22
-22
22 additions, 22 deletions
src/DailymotionScript.ts
with
22 additions
and
22 deletions
src/DailymotionScript.ts
+
22
−
22
View file @
15bed353
...
...
@@ -251,11 +251,11 @@ source.getPlaylist = (url: string): PlatformPlaylistDetails => {
return
getLikePlaylist
(
config
.
id
,
httpClient
,
usePlatformAuth
,
thumbnailResolutionIndex
);
}
if
(
url
===
FAVORITES_PLAYLIST_ID
)
{
if
(
url
===
FAVORITES_PLAYLIST_ID
)
{
return
getFavoritesPlaylist
(
config
.
id
,
httpClient
,
usePlatformAuth
,
thumbnailResolutionIndex
);
}
if
(
url
===
RECENTLY_WATCHED_PLAYLIST_ID
)
{
if
(
url
===
RECENTLY_WATCHED_PLAYLIST_ID
)
{
return
getRecentlyWatchedPlaylist
(
config
.
id
,
httpClient
,
usePlatformAuth
,
thumbnailResolutionIndex
);
}
...
...
@@ -396,11 +396,28 @@ source.getUserPlaylists = (): string[] => {
const
userName
=
(
jsonResponse
?.
data
?.
me
?.
channel
as
Channel
)?.
name
;
return
getPlaylistsByUsername
(
userName
,
headers
,
true
);
const
playlists
=
getPlaylistsByUsername
(
userName
,
headers
,
true
);
[
LIKE_PLAYLIST_ID
,
FAVORITES_PLAYLIST_ID
,
RECENTLY_WATCHED_PLAYLIST_ID
].
forEach
(
playlistId
=>
{
if
(
!
authenticatedPlaylistCollection
.
includes
(
playlistId
))
{
authenticatedPlaylistCollection
.
push
(
playlistId
);
}
if
(
!
playlists
.
includes
(
playlistId
))
{
playlists
.
push
(
playlistId
);
}
});
return
playlists
;
}
function
getPlaylistsByUsername
(
userName
,
headers
,
usePlatformAuth
=
false
)
{
function
getPlaylistsByUsername
(
userName
,
headers
,
usePlatformAuth
=
false
)
:
string
[]
{
const
collections
=
executeGqlQuery
(
...
...
@@ -421,7 +438,7 @@ function getPlaylistsByUsername(userName, headers, usePlatformAuth = false) {
}
);
const
playlists
=
collections
.
data
.
channel
.
collections
.
edges
.
map
(
edge
=>
{
const
playlists
:
string
[]
=
collections
.
data
.
channel
.
collections
.
edges
.
map
(
edge
=>
{
const
playlistUrl
=
`
${
BASE_URL_PLAYLIST
}
/
${
edge
.
node
.
xid
}
`
;
if
(
!
authenticatedPlaylistCollection
.
includes
(
playlistUrl
))
{
authenticatedPlaylistCollection
.
push
(
playlistUrl
);
...
...
@@ -429,23 +446,6 @@ function getPlaylistsByUsername(userName, headers, usePlatformAuth = false) {
return
playlistUrl
;
});
[
LIKE_PLAYLIST_ID
,
FAVORITES_PLAYLIST_ID
,
RECENTLY_WATCHED_PLAYLIST_ID
].
forEach
(
playlistId
=>
{
if
(
!
authenticatedPlaylistCollection
.
includes
(
playlistId
))
{
authenticatedPlaylistCollection
.
push
(
playlistId
);
}
if
(
!
playlists
.
includes
(
playlistId
))
{
playlists
.
push
(
playlistId
);
}
});
return
playlists
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment