summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-11 20:51:08 -0600
committermsglm <msglm@techchud.xyz>2023-01-11 20:51:08 -0600
commit574bbf47e4514f69e9398a5a9f8fa3cd5dd72ceb (patch)
tree7f04a81d731c2ea24820603de79bfd6239de58ca
parentea2410eeb18b495f71dfe6f0a941e5d65078c523 (diff)
downloadcomedyGenerator-574bbf47e4514f69e9398a5a9f8fa3cd5dd72ceb.tar.gz
comedyGenerator-574bbf47e4514f69e9398a5a9f8fa3cd5dd72ceb.tar.bz2
comedyGenerator-574bbf47e4514f69e9398a5a9f8fa3cd5dd72ceb.zip
added gif support
-rwxr-xr-xcomedyGenerator50
-rw-r--r--config13
2 files changed, 53 insertions, 10 deletions
diff --git a/comedyGenerator b/comedyGenerator
index be847a5..76bacb1 100755
--- a/comedyGenerator
+++ b/comedyGenerator
@@ -15,7 +15,7 @@ config = configparser.ConfigParser()
configdir = str(xdg.XDG_CONFIG_HOME)
config.read(configdir + "/comedyGenerator")
-parser = argparse.ArgumentParser(add_help=True)
+parser = argparse.ArgumentParser(add_help=True, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--verbose', '-v',
default=False,
@@ -33,8 +33,7 @@ parser.add_argument('--amount','-a',
)
parser.add_argument('--output','-o',
- default=config['DEFAULT']['output'],
- dest='output',
+ dest=None,
action="store",
help="the output directory of the funnies",
type=str
@@ -56,6 +55,20 @@ parser.add_argument('--jobs','-j',
type=int
)
+parser.add_argument('--type','-t',
+ default=str(config['DEFAULT']['type']),
+ dest='type',
+ action="store",
+ help=
+ '''
+The type of content that will be extracted
+The following arguments are valid (case insensitive):
+Video
+Gifs
+ ''',
+ type=str
+ )
+
parser.add_argument('tags',
nargs='+',
type=str,
@@ -64,6 +77,26 @@ parser.add_argument('tags',
args = parser.parse_args()
+contentFilter = "video"
+
+if args.output == None:
+ if args.verbose:
+ print("Recalibtrating output location")
+ if args.type.lower() == "video" or args.type.lower() == "videos":
+ args.output = config['Videos']['output']
+ elif args.type.lower() == "gifs" or args.type.lower() == "gif":
+ args.output = config['Gifs']['output']
+
+if args.type.lower() == "video" or args.type.lower() == "videos":
+ contentFilter = "video"
+elif args.type.lower() == "gifs" or args.type.lower() == "gif":
+ contentFilter = "gif"
+
+if args.verbose:
+ print("Current output location: " + str(args.output))
+ print("Current filter: " + contentFilter)
+
+
#string comparision so I don't need two vars; bloat kills bloat
logging = False
if not args.log == "False":
@@ -129,7 +162,7 @@ for tags in args.tags:
}
for tries in range(100):
try:
- tagPage = requests.get("https://ifunny.co/api/v1/feeds?filter=video&tag=" + tags, headers=requestHeader, cookies=requestCookies)
+ tagPage = requests.get("https://ifunny.co/api/v1/feeds?filter=" + contentFilter + "&tag=" + tags, headers=requestHeader, cookies=requestCookies)
if args.verbose:
print("Got Webpage!")
except:
@@ -140,13 +173,14 @@ for tags in args.tags:
break
JSONDump = tagPage.json()
+
while len(videos) < args.amount and len(JSONDump['items']) > 0:
- print("Currently have " + str(len(videos)) + " videos out of " + str(args.amount) + " (" + str((len(videos)/args.amount)*100) + "%)")
+ print("Currently have " + str(len(videos)) + " " + contentFilter + " out of " + str(args.amount) + " (" + str((len(videos)/args.amount)*100) + "%)")
for item in range(len(JSONDump['items'])):
videos.append(JSONDump['items'][item]['url'])
for tries in range(100):
try:
- tagPage = requests.get("https://ifunny.co/api/v1/feeds?filter=video&tag=" + tags + "&next=" + JSONDump['pagination']['next'], headers=requestHeader, cookies=requestCookies)
+ tagPage = requests.get("https://ifunny.co/api/v1/feeds?filter=" + contentFilter + "&tag=" + tags + "&next=" + JSONDump['pagination']['next'], headers=requestHeader, cookies=requestCookies)
JSONDump = tagPage.json()
if args.verbose:
print("Got New Tag Page!")
@@ -164,7 +198,9 @@ for tags in args.tags:
def download(video):
if args.verbose:
print("Now running for " + str(video))
- name = tags + "-" + hashlib.md5(video.encode('utf-8')).hexdigest() + ".mp4"
+
+ urlsplit = video.split('.')
+ name = tags + "-" + hashlib.md5(video.encode('utf-8')).hexdigest() + "." + urlsplit[len(urlsplit)-1]
outputPath = args.output + name
if args.verbose:
print("name read as: " + name)
diff --git a/config b/config
index aa8f078..ea44cd3 100644
--- a/config
+++ b/config
@@ -1,9 +1,6 @@
#Move this to ~/.config/comedyGenerator
[DEFAULT]
-#Dictates where videos will be outputted to
-output=./
-
#Location of the log file, if you care about that. False will disable the log file
log=False
@@ -12,3 +9,13 @@ amount=10
#Default amount of jobs used when downloading
jobs=1
+
+[Videos]
+
+#where videos will be outputted to
+output=/home/joybuke/Videos/unsorted/
+
+[Gifs]
+
+#where gifs will be outputted to
+output=/home/joybuke/Pictures/gif/