Skip to content

Instantly share code, notes, and snippets.

@lennier1
Last active December 1, 2024 20:46
Show Gist options
  • Select an option

  • Save lennier1/eeaae73211695016cf64daa8d2467a7a to your computer and use it in GitHub Desktop.

Select an option

Save lennier1/eeaae73211695016cf64daa8d2467a7a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import argparse
def generate_urls(low_id, high_id, v2=False):
if low_id > high_id:
print("Error: low_id must be less than or equal to high_id.")
sys.exit(1)
for id_num in range(low_id, high_id + 1):
id_str = str(id_num)
if v2:
# For -v2, pad the ID to 12 digits (four groups of 3 digits)
id_str_padded = id_str.zfill(12)
# Split into four groups of 3 digits
groups = [id_str_padded[i:i+3] for i in range(0, 12, 3)]
# Build the path with 'video2' prefix
path = 'video2/' + '/'.join(groups)
else:
# For standard URLs, pad the ID to at least 9 digits (three groups of 3 digits)
id_str_padded = id_str.zfill(9)
# Split into groups of 3 digits
groups = [id_str_padded[i:i+3] for i in range(0, 9, 3)]
# Build the path without 'video2' prefix
path = '/'.join(groups)
# Build the small thumbnail URL
small_thumbnail_url = f"asset:cvad.ask.fm/{path}/p_video_answer_{id_num}.jpg"
# Build the big thumbnail URL
big_thumbnail_url = f"asset:cvad.ask.fm/{path}/p_video_answer_{id_num}_big.jpg"
# Build the video URL
video_url = f"asset:cvad.ask.fm/{path}/p_video_answer_{id_num}.mp4"
# Output the items
print(small_thumbnail_url)
print(big_thumbnail_url)
print(video_url)
def main():
parser = argparse.ArgumentParser(description="Generate ask.fm asset video answer items.")
parser.add_argument('low_id', type=int, help='Low ID')
parser.add_argument('high_id', type=int, help='High ID')
parser.add_argument('-v2', action='store_true', help='Use alternate URL structure')
args = parser.parse_args()
generate_urls(args.low_id, args.high_id, args.v2)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment