Guest User

Fap Land script

a guest
Jun 18th, 2020
9,494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.03 KB | None | 0 0
  1. import os, sys
  2. import subprocess
  3. import random
  4. import logging
  5. import time, datetime
  6.  
  7. # Set path to your preferred video player executable
  8. VIDEO_PLAYER = r"E:\MPV\mpv.exe"
  9. # Set path to Fap Land directory, use a dot if the script is in the Fap Land directory itself
  10. PATH = r"."
  11.  
  12. # Set amount of sides for your dice
  13. DIE_SIDES = 6
  14. # Set start position (you cheater)
  15. START = 0
  16. # Skip checkpoint videos
  17. CHECKPOINT_SKIP = False
  18. # Use breaks between rounds
  19. USE_BREAKS = True
  20. # Set break length (seconds)
  21. BREAK_LENGTH = 10
  22.  
  23.  
  24.  
  25.  
  26.  
  27. MAX_ROUNDS = 100
  28.  
  29. log = logging.getLogger()
  30. log.setLevel(logging.INFO)
  31. formatter = logging.Formatter("%(message)s")
  32. stdout = logging.StreamHandler(sys.stdout)
  33. stdout.setFormatter(formatter)
  34. stdout.setLevel(logging.INFO)
  35. log.addHandler(stdout)
  36.  
  37. def wait_for_process(process):
  38.     while process.poll() is None:
  39.         pass
  40.  
  41. def play_round(filename, directory='.'):
  42.     process = subprocess.Popen([VIDEO_PLAYER, os.path.join(directory, filename)])
  43.     wait_for_process(process)
  44.  
  45. if __name__ == "__main__":
  46.     if not os.path.exists(PATH):
  47.         raise Exception("Given directory %r does not exist" % PATH)
  48.     videos = os.listdir(PATH)
  49.     if len(videos) == 0:
  50.         raise Exception("Given directory %r is empty" % PATH)
  51.  
  52.     checkpoint_files = [filename for filename in videos if '-' in filename and filename.endswith('.mp4')]
  53.     checkpoint_files = sorted(checkpoint_files, key=lambda x: int(x[:x.index('-')]))
  54.     checkpoints = [int(filename[:filename.index('-')]) for filename in checkpoint_files]
  55.     checkpoint = 0
  56.     if len(checkpoints) == 0:
  57.         CHECKPOINT_SKIP = True
  58.  
  59.     index = START
  60.     finished = index >= len(videos)
  61.     t_start = time.time()
  62.     while not finished:
  63.         dice_roll = random.randint(1, DIE_SIDES)
  64.         log.info("Rolled a %d" % dice_roll)
  65.         if checkpoint < len(checkpoints) and index < checkpoints[checkpoint] <= index + dice_roll:
  66.             if not CHECKPOINT_SKIP:
  67.                 log.info("Reached checkpoint %d" % (checkpoint+1))
  68.                 play_round(checkpoint_files[checkpoint], PATH)
  69.             if index + dice_roll == checkpoints[checkpoint]:
  70.                 log.info("Landed on checkpoint round")
  71.                 index += 1
  72.             checkpoint += 1
  73.  
  74.         index += dice_roll
  75.         if index > MAX_ROUNDS:
  76.             break
  77.  
  78.         video = "%d.mp4" % index
  79.         if not os.path.exists(os.path.join(PATH, video)):
  80.             log.error("Expected %s to exist but it doesn't, skipping roll" % video)
  81.             continue
  82.  
  83.         current_time = time.time() - t_start
  84.         log.info("Starting round %d [%s]" % (index, datetime.timedelta(seconds=int(current_time))))
  85.         play_round(video, PATH)
  86.         if USE_BREAKS:
  87.             log.info("Counting down to next round")
  88.             for i in range(int(BREAK_LENGTH)):
  89.                 time.sleep(1)
  90.                 log.info(str(i+1))
  91.  
  92.     current_time = time.time() - t_start
  93.     log.info("Finished with a time of [%s]" % datetime.timedelta(seconds=int(current_time)))
Add Comment
Please, Sign In to add comment