Skip to content

Commit

Permalink
Minor comment addition
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C committed Jul 24, 2023
1 parent 3dbb921 commit c8736e3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MESSAGES CONTROL]
disable = bad-continuation, import-error, invalid-name, missing-docstring, multiple-imports, too-few-public-methods, ungrouped-imports, wrong-import-order
disable = bad-continuation, fixme, import-error, invalid-name, missing-docstring, multiple-imports, too-few-public-methods, ungrouped-imports, wrong-import-order

[FORMAT]
max-line-length = 200
33 changes: 21 additions & 12 deletions playlistItems_delete.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
#!/usr/bin/env python3

# Does not work because this endpoint also requires an OAuth2 access token
# INSTALL: pip install google-api-python-client google-auth-oauthlib
# USAGE: ./playlistItems_delete.py $id1 [$id2 ...]

# USAGE: YOUTUBE_API_KEY=... ./playlistItems_delete.py $id1 [$id2 ...]
import os, sys

import os, requests, sys
import google_auth_oauthlib.flow
import googleapiclient.discovery
import googleapiclient.errors


def playlistItems_delete(youtube_api_key, items_ids):
YOUR_CLIENT_SECRET_FILE = "client_secret_CLIENTID.json"


def playlistItems_delete(items_ids):
# Disable OAuthlib's HTTPS verification when running locally.
# os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"

# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
YOUR_CLIENT_SECRET_FILE, scopes=["https://www.googleapis.com/auth/youtube.force-ssl"])
credentials = flow.run_console()
youtube = googleapiclient.discovery.build("youtube", "v3", credentials=credentials)

for item_id in items_ids:
resp = requests.delete('https://www.googleapis.com/youtube/v3/playlistItems', params={
'key': youtube_api_key,
'id': item_id,
})
if resp != 200:
print(resp.text, file=sys.stderr)
resp.raise_for_status()
youtube.playlistItems().delete(id=item_id).execute()


if __name__ == '__main__':
playlistItems_delete(os.environ['YOUTUBE_API_KEY'], sys.argv[1:])
playlistItems_delete(sys.argv[1:])
1 change: 1 addition & 0 deletions youtube_playlist_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def deleted(changeset, args):
for old_item in changeset:
video_name = retrieve_old_video_info_from_prev_dumps(get_video_id(old_item), args).video_name if is_video_deleted(old_item) else get_video_name(old_item)
yield ('DELETED: ' + video_name + ' ' + get_video_url(old_item)
# TODO: insert .playlistItemId (that IS accessible), like for private videos
+ ' ({}th video in the playlist)'.format(old_item['current_index'])
+ '\n -> find another video named like that: ' + get_search_url(video_name))
@staticmethod
Expand Down

0 comments on commit c8736e3

Please sign in to comment.