changeset 40:2aa9614cb39a

flake8
author Paper <mrpapersonic@gmail.com>
date Mon, 21 Jun 2021 15:16:15 -0400
parents a93c352af05e
children 37f231f85a67
files deleteautosave.py getlist.py intro.py nhentai.py peardeck.py pixivimageposter.py remuxaudio.py rename.py sfv.py updatechromium.py
diffstat 10 files changed, 177 insertions(+), 84 deletions(-) [+]
line wrap: on
line diff
--- a/deleteautosave.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/deleteautosave.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,4 +1,4 @@
-import os, sys
+import os
 
 for file in os.listdir("./"):
     name = os.path.splitext(file)[0][:-16][-8:]
--- a/getlist.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/getlist.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,32 +1,39 @@
-import urllib.request, json, re, sys
+import urllib.request
+import json
+import sys
 
 # Initialize variables
-key = "f090bb54758cabf231fb605d3e3e0468" # https://github.com/xbmc/metadata.themoviedb.org.python/blob/master/python/lib/tmdbscraper/tmdbapi.py#L36
+# https://github.com/xbmc/metadata.themoviedb.org.python/blob/master/python/lib/tmdbscraper/tmdbapi.py#L36
+key = "f090bb54758cabf231fb605d3e3e0468"
 
 # Ask for source
-if not 2 >= len(sys.argv): source = sys.argv[1]
-if not 'source' in locals() or not 'source' in globals():
-    source = input("Which website would you like to pull titles from? [tmdb, mal]: ")
+if not 2 >= len(sys.argv):
+    source = sys.argv[1]
+if 'source' not in locals() or 'source' not in globals():
+    source = input(
+        "Which website would you like to pull titles from? [tmdb, mal]: ")
 while source not in ["tmdb", "mal"]:
     print("Not a valid source! Exiting.")
     sys.exit()
 
 # Ask for ID
-if not 3 >= len(sys.argv): source = sys.argv[2]
-if not 'id' in locals() or not 'id' in globals():
+if not 3 >= len(sys.argv):
+    source = sys.argv[2]
+if 'id' not in locals() or 'id' not in globals():
     id = input("What is the ID for your show?: ")
 try:
     temp = int(id)
-except:
+except Exception:
     print("Not a valid ID! Exiting.")
     sys.exit()
 
 # Scrapers
 if source == 'tmdb':
-    season = input("Which season do you want?: ") # required because api is... odd
+    # required because api is... odd
+    season = input("Which season do you want?: ")
     try:
         temp = int(season)
-    except:
+    except Exception:
         print("Not a valid season! Exiting.")
         sys.exit()
     data = json.loads(urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}?api_key={key}').read().decode())
@@ -35,11 +42,13 @@
     f.write("")
     f.close()
     count = 1
-    for i in range(amount): # this may count as spamming the api but i don't care lol
-        with urllib.request.urlopen(f'https://api.themoviedb.org/3/tv/{str(id)}/season/{season}/episode/{count}?api_key={key}') as url:
+    for i in range(amount):  # this may count as spamming the api but i don't care lol
+        with urllib.request.urlopen(
+            f'https://api.themoviedb.org/3/tv/{str(id)}/season/{season}/episode/{count}?api_key={key}') as url:
             data = json.loads(url.read().decode())
             f = open("list.txt", "a", encoding="utf-8")
-            f.write(data["name"].replace("?", "?").replace(":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n")
+            f.write(data["name"].replace("?", "?").replace(
+                ":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n")
             count += 1
             f.close()
 if source == 'mal':
@@ -51,6 +60,7 @@
         f.close()
         for i in range(len(data["episodes"])):
             f = open("list.txt", "a", encoding="utf-8")
-            f.write(data["episodes"][count]["title"].replace("?", "?").replace(":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n")
+            f.write(data["episodes"][count]["title"].replace("?", "?").replace(
+                ":", "꞉").replace('"', "“").split("/")[0].rstrip() + "\n")
             count += 1
             f.close()
--- a/intro.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/intro.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,9 +1,12 @@
-import os
-
-amt = 1
-for files in os.walk("./"):
-    for file in files:
-        ext = os.path.splitext(file)[-1].lower()
-        if ext == ".mkv":
-            os.system(f'ffmpeg -i "{file}" -t 30 -pix_fmt yuv420p "Clips\intro_{amt}.mp4')
-            amt += 1
+import os
+import ffmpeg
+
+amt = 1
+for files in os.walk("./"):
+    for file in files:
+        ext = os.path.splitext(file)[-1].lower()
+        if ext == ".mkv":
+            stream = ffmpeg.input(file)
+            os.system(
+                f'ffmpeg -i "{file}" -t 30 -pix_fmt yuv420p "Clips\intro_{amt}.mp4')
+            amt += 1
--- a/nhentai.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/nhentai.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,17 +1,66 @@
-import os, argparse, sys
+import os
+import argparse
+import sys
+
 
 def main(argv):
     global outputfile
     parser = argparse.ArgumentParser()
-    parser.add_argument('-o', '--output', help="output file, defaults to urls.txt", metavar='<output>', required=True)
+    parser.add_argument(
+        '-o', '--output', help="output file, defaults to urls.txt",
+        metavar='<output>', required=True)
     args = parser.parse_args()
     if args.output:
         outputfile = args.output
-    a = ["257892", "226942", "236297", "216039", "221711", "267371", "235905", "266808", "262036", "206069", "245304", "166174", "175220", "244327", "191049", "147577", "188940", "240543", "165264", "267384", "220882", "244859", "227446", "259322", "259862", "267372", "234932", "247540", "253687", "259569", "259758", "259555", "242505", "255388", "262042", "231290", "250827", "247175", "258728", "264370", "146718", "202230", "259668", "259848", "259542", "266772", "267243", "264901", "263960", "262771", "259420", "188717", "259727", "257889", "259904", "247703", "244427", "242070", "238845", "228510", "258136", "259906", "259986", "216926", "197648", "228426", "225259", "229779", "228922", "103383", "232854", "156069", "122984", "260026", "259634", "160556", "100094", "169468", "204746", "219077", "259610", "259348", "258669", "256097", "118282", "269329", "173023", "186446", "229948", "256088", "260028", "260058", "259557", "259497", "122220", "269582", "270455", "256776", "238651", "242543", "260111", "260088", "259880", "258977", "260097", "263329", "127727", "256789", "256787", "217410", "259765", "259359", "260138", "259617", "107965", "269413", "268926", "208174", "211112", "225664", "197255", "260276", "260209", "260210", "260203", "266834", "196341", "267924", "258212", "248769", "191360", "191390", "248933", "257567", "227913", "219077", "204746", "204066", "007693", "007695", "211648", "210240", "260626", "259622", "257991", "017131", "130602", "172787", "043168", "050856", "213966", "260623", "149112", "252168", "198203", "056657", "064707", "162677", "079712", "167450", "114783", "220958", "244387", "243734", "223315", "102346", "183783", "114427", "119726", "142154", "118069", "136188", "260686", "241777", "260912", "152889", "186055", "204746", "270536", "270528", "142154", "119298", "261174", "258301", "256808", "270415", "270393", "270240", "269871", "269834", "169134", "220354", "260271", "261725", "261378", "269821", "269740", "269721", "269672", "269649", "252174", "261928", "114427", "187003", "147572", "269638", "269434", "269279", "256302", "242517", "249458", "157767", "224316", "175294", "258450", "212347", "268820", "268306", "266301", "265066", "233864", "236128", "261162", "174036", "187205", "270424", "269374", "269067", "268742", "267859", "210873", "193318", "110232", "199310", "193816", "270629", "270628", "270517", "270435", "270174", "220376", "193814", "193815", "219068", "220386", "269064", "269653", "279474", "269366", "268487", "177642", "188269", "181837", "220377", "119293", "268328", "268423", "267935", "265575", "265453", "257528", "258926", "262384", "105951", "259904", "265002", "265085", "270559", "270347", "266882", "208174", "249229", "245644", "262538", "234818", "266442", "264901", "263960", "262771", "262326", "216845", "149212", "134442", "135927", "262447", "261539", "269370", "258301", "256785", "256808", "261811", "261650", "261225", "261226", "260761", "255351", "253306", "242070", "235763", "230437", "250327", "192327", "167801", "150309", "123554", "233736", "260606", "253099", "236707", "231576"]
+    a = ["257892", "226942", "236297", "216039", "221711", "267371", "235905",
+         "266808", "262036", "206069", "245304", "166174", "175220", "244327",
+         "191049", "147577", "188940", "240543", "165264", "267384", "220882",
+         "244859", "227446", "259322", "259862", "267372", "234932", "247540",
+         "253687", "259569", "259758", "259555", "242505", "255388", "262042",
+         "231290", "250827", "247175", "258728", "264370", "146718", "202230",
+         "259668", "259848", "259542", "266772", "267243", "264901", "263960",
+         "262771", "259420", "188717", "259727", "257889", "259904", "247703",
+         "244427", "242070", "238845", "228510", "258136", "259906", "259986",
+         "216926", "197648", "228426", "225259", "229779", "228922", "103383",
+         "232854", "156069", "122984", "260026", "259634", "160556", "100094",
+         "169468", "204746", "219077", "259610", "259348", "258669", "256097",
+         "118282", "269329", "173023", "186446", "229948", "256088", "260028",
+         "260058", "259557", "259497", "122220", "269582", "270455", "256776",
+         "238651", "242543", "260111", "260088", "259880", "258977", "260097",
+         "263329", "127727", "256789", "256787", "217410", "259765", "259359",
+         "260138", "259617", "107965", "269413", "268926", "208174", "211112",
+         "225664", "197255", "260276", "260209", "260210", "260203", "266834",
+         "196341", "267924", "258212", "248769", "191360", "191390", "248933",
+         "257567", "227913", "219077", "204746", "204066", "007693", "007695",
+         "211648", "210240", "260626", "259622", "257991", "017131", "130602",
+         "172787", "043168", "050856", "213966", "260623", "149112", "252168",
+         "198203", "056657", "064707", "162677", "079712", "167450", "114783",
+         "220958", "244387", "243734", "223315", "102346", "183783", "114427",
+         "119726", "142154", "118069", "136188", "260686", "241777", "260912",
+         "152889", "186055", "204746", "270536", "270528", "142154", "119298",
+         "261174", "258301", "256808", "270415", "270393", "270240", "269871",
+         "269834", "169134", "220354", "260271", "261725", "261378", "269821",
+         "269740", "269721", "269672", "269649", "252174", "261928", "114427",
+         "187003", "147572", "269638", "269434", "269279", "256302", "242517",
+         "249458", "157767", "224316", "175294", "258450", "212347", "268820",
+         "268306", "266301", "265066", "233864", "236128", "261162", "174036",
+         "187205", "270424", "269374", "269067", "268742", "267859", "210873",
+         "193318", "110232", "199310", "193816", "270629", "270628", "270517",
+         "270435", "270174", "220376", "193814", "193815", "219068", "220386",
+         "269064", "269653", "279474", "269366", "268487", "177642", "188269",
+         "181837", "220377", "119293", "268328", "268423", "267935", "265575",
+         "265453", "257528", "258926", "262384", "105951", "259904", "265002",
+         "265085", "270559", "270347", "266882", "208174", "249229", "245644",
+         "262538", "234818", "266442", "264901", "263960", "262771", "262326",
+         "216845", "149212", "134442", "135927", "262447", "261539", "269370",
+         "258301", "256785", "256808", "261811", "261650", "261225", "261226",
+         "260761", "255351", "253306", "242070", "235763", "230437", "250327",
+         "192327", "167801", "150309", "123554", "233736", "260606", "253099",
+         "236707", "231576"]
     if os.path.exists(outputfile):
         answer = ""
         while answer not in ["y", "n", "yes", "no"]:
-            print(f"{outputfile} still exists. Delete it? [y/n]: ", end = "")
+            print(f"{outputfile} still exists. Delete it? [y/n]: ", end="")
             answer = input().lower()
         if answer in ["y", "yes"]:
             os.remove(outputfile)
@@ -22,5 +71,7 @@
         myfile.write(f"https://nhentai.org/g/{i}\n")
         myfile.close()
     print("URLs successfully written!")
+
+
 if __name__ == "__main__":
     main(sys.argv[1:])
--- a/peardeck.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/peardeck.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,42 +1,58 @@
-# function for encrypting to a1z26 cause i'm lazy
-def A1Z26_encrypt(cistring):
-    string = []
-    cistring = cistring.lower()
-    cistring = "".join(cistring.split())
-    for x in range(0, len(cistring)):
-        char = ord(cistring[x]) - 96
-        if char > 0 and char <= 26: string.append(int(char)-1)
-    return(string)
-
-# define variables
-o=["Avocados", "Bandanas", "Carrots", "Drums", "Elephants", "Flashlights", "Grapes", "Highlighters", "Incentives", "Jacks", "Kangaroos", "Lemons", "Muffins", "Ninjas", "Olives", "Pears", "Quizzes", "Raisins", "Submarines", "Turnips", "Umbrellas", "Violas", "Watermelons", "X-Rays", "Yards", "Zebras"]
-a=["Acidic", "Broke", "Confused", "Determined", "Exothermic", "Fragrant", "Green", "Hilarious", "Insincere", "Juicy", "Keen", "Lovely", "Misty", "New", "Orange", "Purple", "Quick", "Red", "Stoic", "Troubling", "Underwhelmed", "Victorious", "Warm", "Xeric", "Young", "Zesty"]
-s=["Always", "Bravely", "Calmly", "Daringly", "Easily", "Fondly", "Gladly", "Honestly", "Instantly", "Joyfully", "Kindly", "Loudly", "Magically", "Neatly", "Openly", "Perfectly", "Quietly", "Rarely", "Safely", "Tenderly", "Usually", "Victoriously", "Warmly", "Xerically", "Yearly", "Zestfully"]
-c=["Award", "Bother", "Conduct", "Drive", "Evaluate", "Form", "Give", "Help", "Inspect", "Jump", "Keep", "Lift", "Memorize", "Notice", "Officiate", "Pursue", "Quiz", "Raise", "Switch", "Turn", "Underwhelm", "Vacate", "Wish", "X-Ray", "Yield", "Zip"]
-
-# the actual start of the code
-print("what is your peardeck code?: ")
-i = input().lower()
-ilist = A1Z26_encrypt(i)
-try:
-	temp = a[ilist[0]]
-except IndexError:
-	print("ERROR: Please input letters.")
-except:
-	print("ERROR: Unknown error occurred!")
-if (len(i) == 6):
-	print(a[ilist[0]] + " ", end="")
-	print(o[ilist[1]] + " ", end="")
-	print(s[ilist[2]] + " ", end="")
-	print(c[ilist[3]] + " ", end="")
-	print(a[ilist[4]] + " ", end="")
-	print(o[ilist[5]], end="")
-elif (len(i) == 5):
-	print(a[ilist[0]] + " ", end="")
-	print(o[ilist[1]] + " ", end="")
-	print(c[ilist[2]] + " ", end="")
-	print(a[ilist[3]] + " ", end="")
-	print(o[ilist[4]], end="")
-else:
-	print("invalid input, exiting")
-	exit()
+# function for encrypting to a1z26 cause i'm lazy
+def A1Z26_encrypt(cistring):
+    string = []
+    cistring = cistring.lower()
+    cistring = "".join(cistring.split())
+    for x in range(0, len(cistring)):
+        char = ord(cistring[x]) - 96
+        if char > 0 and char <= 26:
+            string.append(int(char)-1)
+    return(string)
+
+
+# define variables
+o = ["Avocados", "Bandanas", "Carrots", "Drums", "Elephants", "Flashlights",
+     "Grapes", "Highlighters", "Incentives", "Jacks", "Kangaroos", "Lemons",
+     "Muffins", "Ninjas", "Olives", "Pears", "Quizzes", "Raisins",
+     "Submarines", "Turnips", "Umbrellas", "Violas", "Watermelons", "X-Rays",
+     "Yards", "Zebras"]
+a = ["Acidic", "Broke", "Confused", "Determined", "Exothermic", "Fragrant",
+     "Green", "Hilarious", "Insincere", "Juicy", "Keen", "Lovely", "Misty",
+     "New", "Orange", "Purple", "Quick", "Red", "Stoic", "Troubling",
+     "Underwhelmed", "Victorious", "Warm", "Xeric", "Young", "Zesty"]
+s = ["Always", "Bravely", "Calmly", "Daringly", "Easily", "Fondly", "Gladly",
+     "Honestly", "Instantly", "Joyfully", "Kindly", "Loudly", "Magically",
+     "Neatly", "Openly", "Perfectly", "Quietly", "Rarely", "Safely",
+     "Tenderly", "Usually", "Victoriously", "Warmly", "Xerically", "Yearly",
+     "Zestfully"]
+c = ["Award", "Bother", "Conduct", "Drive", "Evaluate", "Form", "Give", "Help",
+     "Inspect", "Jump", "Keep", "Lift", "Memorize", "Notice", "Officiate",
+     "Pursue", "Quiz", "Raise", "Switch", "Turn", "Underwhelm", "Vacate",
+     "Wish", "X-Ray", "Yield", "Zip"]
+
+# the actual start of the code
+print("what is your peardeck code?: ")
+i = input().lower()
+ilist = A1Z26_encrypt(i)
+try:
+    temp = a[ilist[0]]
+except IndexError:
+    print("ERROR: Please input letters.")
+except Exception:
+    print("ERROR: Unknown error occurred!")
+if (len(i) == 6):
+    print(a[ilist[0]] + " ", end="")
+    print(o[ilist[1]] + " ", end="")
+    print(s[ilist[2]] + " ", end="")
+    print(c[ilist[3]] + " ", end="")
+    print(a[ilist[4]] + " ", end="")
+    print(o[ilist[5]], end="")
+elif (len(i) == 5):
+    print(a[ilist[0]] + " ", end="")
+    print(o[ilist[1]] + " ", end="")
+    print(c[ilist[2]] + " ", end="")
+    print(a[ilist[3]] + " ", end="")
+    print(o[ilist[4]], end="")
+else:
+    print("invalid input, exiting")
+    exit()
--- a/pixivimageposter.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/pixivimageposter.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,14 +1,18 @@
-import glob, os, random, discord
+import glob
+import random
+import discord
 from discord.ext import commands
 
 help_command = commands.DefaultHelpCommand(no_category="Commands")
-client = commands.Bot(command_prefix = '!!',help_command = help_command)
+client = commands.Bot(command_prefix='!!', help_command=help_command)
+
 
 @client.event
 async def on_ready():
     print("Ready!")
 
-@client.command(help = "Posts a random image from my pixiv bookmarks")
+
+@client.command(help="Posts a random image from my pixiv bookmarks")
 async def pixiv(ctx):
     files = glob.glob("*.png")
     files.extend(glob.glob("*.jpg"))
@@ -18,13 +22,16 @@
     filenames are the default to pixivutil2, being
     "(id)_p(imgnumber) - (title).(ext)"
 
-    link1 takes "file" and splits it with the character "_", giving you the id and the rest of the file
+    link1 takes "file" and splits it with the character "_",
+    giving you the id and the rest of the file
 
-    link2 takes the rest of the file and splits it with a space, giving you the image number and other stuff we don't need
-    it then removes "p" which just gets in the way, converts it to an integer, and adds 1 to it because pixivutil2 uses an initial zero in numbering
+    link2 takes the rest of the file and splits it with a space,
+    giving you the image number and other stuff we don't need
+    it then removes "p" which just gets in the way, converts it to an integer,
+    and adds 1 to it because pixivutil2 uses an initial zero in numbering
     '''
     link1 = file.split("_", 1)[0]
     link2 = int(file.split("_", 1)[1].split(" ", 1)[0].replace('p', ''))+1
-    await ctx.send("https://pixiv.net/member_illust.php?mode=medium&illust_id=" + link1 + ", Image " + str(link2),file = discord.File(file))
+    await ctx.send(f"https://pixiv.net/member_illust.php?mode=medium&illust_id={link1}, Image {str(link2)}", file=discord.File(file))
 
 client.run("token")
--- a/remuxaudio.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/remuxaudio.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,4 +1,4 @@
-import os, sys
+import os
 
 count = 0
 for path, folder, files in os.walk("./"):
@@ -8,4 +8,4 @@
             file_mod = file[:len(file) - 15]
             file_mod = f'KIZNAIVER - {count:02} [{file_mod[7:]}]'
             os.system(f'mkvmerge -o "output\{file_mod}.mkv" --audio-tracks 2 --subtitle-tracks 6 "{file}"')
-            os.system(f'mkvpropedit --delete-attachment mime-type:image/jpeg "output\{file_mod}.mkv"')
\ No newline at end of file
+            os.system(f'mkvpropedit --delete-attachment mime-type:image/jpeg "output\{file_mod}.mkv"')
--- a/rename.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/rename.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,4 +1,5 @@
-import os, sys
+import os
+import sys
 
 # valid filename: "[title] - [episode number].mkv"
 for file in os.listdir("./"):
--- a/sfv.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/sfv.py	Mon Jun 21 15:16:15 2021 -0400
@@ -1,10 +1,14 @@
-import os, sys, zlib
+import sys
+import zlib
+
 
-def crc(filename): return "%X"%(zlib.crc32(open(filename,"rb").read()) & 0xFFFFFFFF)
+def crc(filename): return "%X" % (zlib.crc32(
+    open(filename, "rb").read()) & 0xFFFFFFFF)
+
 
 try:
     temp = sys.argv[1]
-except:
+except Exception:
     print("No file specified!")
     sys.exit()
 
--- a/updatechromium.py	Mon Jun 21 13:58:31 2021 -0400
+++ b/updatechromium.py	Mon Jun 21 15:16:15 2021 -0400
@@ -68,7 +68,8 @@
     sys.exit(1)
 owner = "ungoogled-software"
 repo = "ungoogled-chromium-archlinux"
-json = json.loads(urllib.request.urlopen(f"https://api.github.com/repos/{owner}/{repo}/releases").read())
+json = json.loads(urllib.request.urlopen(
+    f"https://api.github.com/repos/{owner}/{repo}/releases").read())
 check_version(json[0]["tag_name"])
 for i in json[0]["assets"]:
     if i["content_type"] == "application/octet-stream":