Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, sys
- import subprocess
- import random
- import logging
- import time, datetime
- # Set path to your preferred video player executable
- VIDEO_PLAYER = r"E:\MPV\mpv.exe"
- # Set path to Fap Land directory, use a dot if the script is in the Fap Land directory itself
- PATH = r"."
- # Set amount of sides for your dice
- DIE_SIDES = 6
- # Set start position (you cheater)
- START = 0
- # Skip checkpoint videos
- CHECKPOINT_SKIP = False
- # Use breaks between rounds
- USE_BREAKS = True
- # Set break length (seconds)
- BREAK_LENGTH = 10
- MAX_ROUNDS = 100
- log = logging.getLogger()
- log.setLevel(logging.INFO)
- formatter = logging.Formatter("%(message)s")
- stdout = logging.StreamHandler(sys.stdout)
- stdout.setFormatter(formatter)
- stdout.setLevel(logging.INFO)
- log.addHandler(stdout)
- def wait_for_process(process):
- while process.poll() is None:
- pass
- def play_round(filename, directory='.'):
- process = subprocess.Popen([VIDEO_PLAYER, os.path.join(directory, filename)])
- wait_for_process(process)
- if __name__ == "__main__":
- if not os.path.exists(PATH):
- raise Exception("Given directory %r does not exist" % PATH)
- videos = os.listdir(PATH)
- if len(videos) == 0:
- raise Exception("Given directory %r is empty" % PATH)
- checkpoint_files = [filename for filename in videos if '-' in filename and filename.endswith('.mp4')]
- checkpoint_files = sorted(checkpoint_files, key=lambda x: int(x[:x.index('-')]))
- checkpoints = [int(filename[:filename.index('-')]) for filename in checkpoint_files]
- checkpoint = 0
- if len(checkpoints) == 0:
- CHECKPOINT_SKIP = True
- index = START
- finished = index >= len(videos)
- t_start = time.time()
- while not finished:
- dice_roll = random.randint(1, DIE_SIDES)
- log.info("Rolled a %d" % dice_roll)
- if checkpoint < len(checkpoints) and index < checkpoints[checkpoint] <= index + dice_roll:
- if not CHECKPOINT_SKIP:
- log.info("Reached checkpoint %d" % (checkpoint+1))
- play_round(checkpoint_files[checkpoint], PATH)
- if index + dice_roll == checkpoints[checkpoint]:
- log.info("Landed on checkpoint round")
- index += 1
- checkpoint += 1
- index += dice_roll
- if index > MAX_ROUNDS:
- break
- video = "%d.mp4" % index
- if not os.path.exists(os.path.join(PATH, video)):
- log.error("Expected %s to exist but it doesn't, skipping roll" % video)
- continue
- current_time = time.time() - t_start
- log.info("Starting round %d [%s]" % (index, datetime.timedelta(seconds=int(current_time))))
- play_round(video, PATH)
- if USE_BREAKS:
- log.info("Counting down to next round")
- for i in range(int(BREAK_LENGTH)):
- time.sleep(1)
- log.info(str(i+1))
- current_time = time.time() - t_start
- log.info("Finished with a time of [%s]" % datetime.timedelta(seconds=int(current_time)))
Add Comment
Please, Sign In to add comment