def test_valid_with_www(): """ Test if the input link containing www.imgur.com does not raise exception. """ try: Imgur('http://www.imgur.com/jedEzFL') except ImgurException: pytest.fail('Exception raised, but not expected.')
__status__ = 'Production' def parse_arguments(): """ Parse input arguments of the program. """ parser = ArgumentParser(description='Imgur downloader') parser.add_argument('-v', '--verbose', help='display download progress and information', action='store_true') parser.add_argument('URL', help='source link') parser.add_argument('directory', help='destination directory') args = parser.parse_args() return (args.verbose, args.URL, args.directory) if __name__ == '__main__': verbose, url, destination = parse_arguments() imgur = Imgur(url) imgur.prepare_images() imgur.numerate_images() downloader = Downloader(imgur.images, destination, verbose) downloader.download()
def test_invalid_link_almost_correct(): """ Test if the class raises exception for invalid link. """ with pytest.raises(ImgurException): Imgur('http://.iimgur.com/jedEzFL')
def test_invalid_link_with_multiple_s(): """ Test if the class raises exception for invalid link. """ with pytest.raises(ImgurException): Imgur('httpssssss://i.imgur.com/jedEzFL')
def album_gallery(): return Imgur('http://imgur.com/gallery/vTTHZ')
def test_invalid_link_with_variation(): """ Test if the class raises exception for invalid link. """ with pytest.raises(ImgurException): Imgur('https://www.reddit.com/imgur.com')
def album_grid(): return Imgur('http://imgur.com/a/vTTHZ?grid')
def album_a(): return Imgur('http://imgur.com/a/vTTHZ')
def single_image_without_extension(): return Imgur('http://imgur.com/jedEzFL')
def single_image_i(): return Imgur('http://i.imgur.com/jedEzFL.jpg')
#!/usr/bin/env python3 from imgur.imgur import Imgur from tools import utils if __name__ == "__main__": a = Imgur(cfgfile="./settings/auth.ini") # albdict = a.albums() # print(albdict) # imglist = a.get_images_from_album('boQrL') # print(imglist) utils.download(link='http://i.imgur.com/eSVGBik.jpg', filename='eSVGBik.jpg')