Skip to content

Commit

Permalink
Add --clipper flag to filter by clip creator
Browse files Browse the repository at this point in the history
  • Loading branch information
Fittiboy committed Feb 28, 2021
1 parent 3a86501 commit e27ba9f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions clipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def get_gdrive_files(credentials, clips, staging):
return files, staging_folder, drive


def get_urls(twitch, start, end, b_id, pagination=None):
def get_urls(twitch, start, end, b_id, pagination=None, clipper=None):
clips_list = []
global game_ids

Expand All @@ -54,6 +54,7 @@ def get_urls(twitch, start, end, b_id, pagination=None):
thumb_url = clip["thumbnail_url"]
clip_url = thumb_url.split("-preview", 1)[0] + ".mp4"
game_id = clip["game_id"]
creator = clip["creator_name"]
game = game_ids.get(game_id, None)
if not game:
game = twitch.get_games(game_ids=game_id)
Expand All @@ -65,8 +66,11 @@ def get_urls(twitch, start, end, b_id, pagination=None):
game_ids[game_id] = game
c_title = " ".join(clip["title"].split("/"))
title = clip["created_at"] + " _ " + game + " _ " + c_title
title += " _ " + clip["creator_name"] + " _ " + clip["id"]
clips_list.append([title, clip_url])
title += " _ " + creator + " _ " + clip["id"]
if clipper and clipper.lower() != creator.lower():
pass
else:
clips_list.append([title, clip_url])

cursor = clips["pagination"].get("cursor", "DONE")

Expand Down Expand Up @@ -110,6 +114,10 @@ def dl_progress(count, block_size, total_size):
help="store clips locally (only necessary " +
"if credentials.txt for Google Drive is present)",
action="store_true")
parser.add_argument("--clipper",
help="only download clips made by this person",
metavar="username",
type=str)
args = parser.parse_args()

filepath = realpath(__file__)
Expand Down Expand Up @@ -204,7 +212,8 @@ def dl_progress(count, block_size, total_size):
start=start,
end=start + timedelta(days=1),
b_id=b_id,
pagination=pagination)
pagination=pagination,
clipper=args.clipper)
all_urls += new_urls
print(f"Clips created on {datestring}: " + str(len(all_urls)),
end="\r")
Expand Down

0 comments on commit e27ba9f

Please sign in to comment.