Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaveMyPlaylist
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
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
Robert Goldmann
SaveMyPlaylist
Commits
4fb28395
Commit
4fb28395
authored
5 years ago
by
Robert Goldmann
Browse files
Options
Downloads
Patches
Plain Diff
members should be accessible by debugger
parent
8c669ece
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
SaveMyPlaylist.py
+11
-11
11 additions, 11 deletions
SaveMyPlaylist.py
with
11 additions
and
11 deletions
SaveMyPlaylist.py
+
11
−
11
View file @
4fb28395
...
...
@@ -42,10 +42,10 @@ class SaveMyPlaylist:
def
__init__
(
self
,
apiKey
,
playlistId
):
print
(
'
### SaveMyPlaylist v{} ###
'
.
format
(
'
.
'
.
join
(
str
(
i
)
for
i
in
VERSION
)))
print
(
'
=============================
\n
'
)
self
.
_
_
apiKey
=
apiKey
self
.
_
_
playlistId
=
playlistId
self
.
_
_
youtubeApi
=
googleapiclient
.
discovery
.
build
(
self
.
API_NAME
,
self
.
API_VERSION
,
developerKey
=
self
.
_
_
apiKey
)
self
.
_
_
items
=
self
.
__fetch_all_playlist_items
()
self
.
_apiKey
=
apiKey
self
.
_playlistId
=
playlistId
self
.
_youtubeApi
=
googleapiclient
.
discovery
.
build
(
self
.
API_NAME
,
self
.
API_VERSION
,
developerKey
=
self
.
_apiKey
)
self
.
_items
=
self
.
__fetch_all_playlist_items
()
def
__fetch_all_playlist_items
(
self
):
items
=
[]
...
...
@@ -60,15 +60,15 @@ class SaveMyPlaylist:
def
__fetch_playlist_items
(
self
,
nextPageToken
=
None
):
if
nextPageToken
is
None
or
nextPageToken
==
0
:
request
=
self
.
_
_
youtubeApi
.
playlistItems
().
list
(
request
=
self
.
_youtubeApi
.
playlistItems
().
list
(
part
=
'
snippet
'
,
playlistId
=
self
.
_
_
playlistId
,
playlistId
=
self
.
_playlistId
,
maxResults
=
50
,
)
else
:
request
=
self
.
_
_
youtubeApi
.
playlistItems
().
list
(
request
=
self
.
_youtubeApi
.
playlistItems
().
list
(
part
=
'
snippet
'
,
playlistId
=
self
.
_
_
playlistId
,
playlistId
=
self
.
_playlistId
,
maxResults
=
50
,
pageToken
=
nextPageToken
)
...
...
@@ -100,14 +100,14 @@ class SaveMyPlaylist:
print
(
'
\n
>>> Started Downloading...
'
)
newVideos
=
[]
for
idx
,
item
in
enumerate
(
self
.
_
_
items
):
for
idx
,
item
in
enumerate
(
self
.
_items
):
fileName
=
'
{} - {}.mp4
'
.
format
(
item
[
self
.
TITLE
],
item
[
self
.
CHANNEL
])
fileName
=
self
.
__escape_file_name
(
fileName
)
if
fileName
in
downloadedVideos
:
print
(
'
Skipping {}/{}:
"
{}
"
as it already exists
'
.
format
(
idx
+
1
,
len
(
self
.
_
_
items
),
fileName
))
print
(
'
Skipping {}/{}:
"
{}
"
as it already exists
'
.
format
(
idx
+
1
,
len
(
self
.
_items
),
fileName
))
continue
print
(
'
Downloading {}/{}:
"
{}
"'
.
format
(
idx
+
1
,
len
(
self
.
_
_
items
),
fileName
))
print
(
'
Downloading {}/{}:
"
{}
"'
.
format
(
idx
+
1
,
len
(
self
.
_items
),
fileName
))
newVideos
.
append
(
item
)
ydl_opts
=
{
...
...
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