Last active
May 12, 2020 03:48
-
-
Save m3adow/f83dcd369731c297d3dc68a62664841a to your computer and use it in GitHub Desktop.
Created by request in /r/twitch: https://www.reddit.com/r/Twitch/comments/4q1ygm/anybody_good_with_json_and_obs/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import argparse | |
from time import sleep | |
def parse_args(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('input_file', metavar='INPUT') | |
parser.add_argument('output_file', metavar='OUTPUT') | |
return parser.parse_args() | |
args=parse_args() | |
while True: | |
try: | |
with open(args.input_file) as myinput: | |
myjson = json.load(myinput) | |
with open(args.output_file, 'w') as myoutput: | |
myoutput.write("%s - %s" % (myjson['song']['artist'], myjson['song']['title'])) | |
except FileNotFoundError as e: | |
print("Couldn't find file '%s'" % e) | |
sleep(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traceback (most recent call last): File "C:\Users\epicl\Desktop\artist_info_pvfm.py", line 21, in <module> except FileNotFoundError as e: NameError: name 'FileNotFoundError' is not defined