Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only import requests in flickr mode #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion glitch_random.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import sys
import getopt
import webbrowser
import requests
from PIL import Image
from collections import Counter, defaultdict
from StringIO import StringIO
Expand Down Expand Up @@ -69,6 +68,7 @@ def __init__(self, path, from_file = False, outdir = '.'):

# if not from_file, path is a URL to image online
else:
import requests
self.data = requests.get(path).content
# use regex to extract name (id) for image from end of URL
# after final backslash (greedy match) but before '_'
Expand Down
3 changes: 2 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os, subprocess, glob
import re
import webbrowser, requests
import webbrowser
import random


Expand Down Expand Up @@ -60,6 +60,7 @@ def random(self, pop_open=True, write=False):
if write:
# write image data to file in directory specified by global PATH_OUT
outfile = outfile_path( self.outdir, '{}.jpg'.format(d_hit['id']) )
import requests
with open(outfile, "w") as file_out:
file_out.write( requests.get(hit_url).content )

Expand Down