Skip to content

Commit

Permalink
Add category filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Fittiboy committed Mar 1, 2021
1 parent f5bbf05 commit 69e1ed4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions clipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_gdrive_files(credentials, clips, staging):
return files, staging_folder, drive


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

Expand All @@ -71,6 +71,8 @@ def get_urls(twitch, start, end, b_id, pagination=None, clipper=None):
title += " _ " + creator + " _ " + clip["id"]
if clipper and clipper.lower() != creator.lower():
pass
elif category and category.lower() != game.lower():
pass
else:
clips_list.append([title, clip_url])

Expand Down Expand Up @@ -120,6 +122,13 @@ def dl_progress(count, block_size, total_size):
help="only download clips made by this person",
metavar="username",
type=str)
parser.add_argument("--category",
help="only download clips from this category/game " +
"(some non-game categories like don't get " +
"reported by the API, so type \"NOGAME\" " +
"for these if you notice they're missing)",
metavar="game",
type=str)
args = parser.parse_args()

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

0 comments on commit 69e1ed4

Please sign in to comment.