コード例 #1
0
						'Optimize',
						filename])

def postGif(filename, quote, tags):
	reduceGif(filename)

	photo = open(filename, 'rb')

	post = t.post('post', blog_url=BLOG_URL, params={'type':'photo', 'caption': quote, 'data': photo, 'tags': ', '.join(tags)})

if __name__ == '__main__':
	while True:
		choice = random.choice(choices)
		tags = []
		try:
			quote = makeGif(choice, 0, rand=True, frames=20)
		except KeyboardInterrupt:
			print "Ouch..."
			exit()
		except:
			print "Unexpected error..."
			print "was trying to make gif from: " + str(choice)
			continue
		quote = ' '.join(quote)
		m = re.search('\s\(\d\d\d\d\)', choice['name'])
		if m != None:
			title = choice['name'][:m.start()]
		else:
			m = re.search('[\s.]S\d\dE\d\d', choice['name'])
			if m != None:
				title = choice['name'][:m.start()]
コード例 #2
0
config = ConfigParser.ConfigParser()
config.read("config.cfg")
config.sections()
CLIENT_ID = config.get("imgur", "client_id")
API_KEY = config.get("imgur", "api_key")
APP_KEY = config.get("twitter", "app_key")
APP_SECRET = config.get("twitter", "app_secret")
OAUTH_TOKEN = config.get("twitter", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("twitter", "oauth_token_secret")

headers = {"Authorization": "Client-ID " + CLIENT_ID}
url = "https://api.imgur.com/3/upload.json"

while True:
    quote = makeGif(random.randint(4, 6), 0, rand=True)
    quote = ' '.join(quote)

    # first pass reduce the amount of colors
    if (os.path.getsize('star_wars.gif') > 4194304):
        subprocess.call([
            'convert', 'star_wars.gif', '-layers', 'Optimize', '-colors',
            '128', 'star_wars.gif'
        ])

    # second pass reduce the amount of colors
    if (os.path.getsize('star_wars.gif') > 4194304):
        subprocess.call([
            'convert', 'star_wars.gif', '-layers', 'Optimize', '-colors', '64',
            'star_wars.gif'
        ])
コード例 #3
0
config = ConfigParser.ConfigParser()
config.read("config.cfg")
config.sections()
CLIENT_ID = config.get("imgur", "client_id")
API_KEY = config.get("imgur", "api_key")
APP_KEY = config.get("twitter", "app_key")
APP_SECRET = config.get("twitter", "app_secret")
OAUTH_TOKEN = config.get("twitter", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("twitter", "oauth_token_secret")

headers = {"Authorization": "Client-ID " + CLIENT_ID}
url = "https://api.imgur.com/3/upload.json"

while True:
	quote = makeGif(random.randint(4,6), 0, rand=True)
	quote = ' '.join(quote)

	# first pass reduce the amount of colors
	if(os.path.getsize('star_wars.gif') > 4194304):
		subprocess.call(['convert',
						'star_wars.gif',
						'-layers',
						'Optimize',
						'-colors',
						'128',
						'star_wars.gif'])

	# second pass reduce the amount of colors
	if(os.path.getsize('star_wars.gif') > 4194304):
		subprocess.call(['convert',
コード例 #4
0
CONSUMER_KEY = config.get("tumblr", "consumer_key")
CONSUMER_SECRET = config.get("tumblr", "consumer_secret")
OAUTH_TOKEN = config.get("tumblr", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("tumblr", "oauth_token_secret")

t = Tumblpy(
    CONSUMER_KEY,
    CONSUMER_SECRET,
    OAUTH_TOKEN,
    OAUTH_TOKEN_SECRET,
)

while True:
    # you can set many more options, check the makeGif-function
    quote = makeGif(random.choice(slug), frames=20)
    quote = ' '.join(quote)

    # reduce amount of colors, because tumblr sucks
    subprocess.call([
        'convert', 'barbarella.gif', '-layers', 'optimize', '-colors', '64',
        '-loop', '0', 'barbarella.gif'
    ])

    while (os.path.getsize('barbarella.gif') > 1048576):
        subprocess.call([
            'convert', 'barbarella.gif', '-resize', '90%', '-coalesce',
            '-layers', 'optimize', '-loop', '0', 'barbarella.gif'
        ])

    photo = open('barbarella.gif', 'rb')
コード例 #5
0
headers = {"Authorization": "Client-ID " + CLIENT_ID}
url = "https://api.imgur.com/3/upload.json"

episodes = [
    101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 201, 202, 203,
    204, 205, 206, 207, 208, 209, 210, 211, 212, 301, 302, 303, 304, 305, 306,
    307, 308, 309, 310, 311, 312, 401, 402, 403, 404, 405, 406, 407, 408, 409,
    410, 411, 412
]

while True:
    while True:
        try:
            quote = makeGif(random.choice(episodes),
                            0,
                            rand=True,
                            no_quote=False)
            quote = ' '.join(quote)
        except:
            continue
        else:
            break

    # first pass reduce the amount of colors
    if (os.path.getsize('star_wars.gif') > 5242880):
        subprocess.call([
            'convert', 'star_wars.gif', '-layers', 'Optimize', '-colors',
            '128', '-loop', '0', 'star_wars.gif'
        ])

    # second pass reduce the amount of colors
コード例 #6
0
                    urwid.AttrMap(done, None, focus_map='reversed')]))


def generate_gif(button):
    raise urwid.ExitMainLoop()


def generate_gif_with_subtitle(button, edit):
    global subtitle
    subtitle = edit.edit_text
    raise urwid.ExitMainLoop()


def exit(button):
    index = None
    raise urwid.ExitMainLoop()


main = urwid.Padding(menu(u'Movie choice', choices), left=2, right=2)
top = urwid.Overlay(main,
                    urwid.SolidFill(u'\N{MEDIUM SHADE}'),
                    align='center',
                    width=('relative', 60),
                    valign='middle',
                    height=('relative', 60),
                    min_width=20,
                    min_height=9)
urwid.MainLoop(top, palette=[('reversed', 'standout', '')]).run()
if index:
    makeGif(source, index, custom_subtitle=subtitle)
コード例 #7
0
def generate_gif_with_subtitle(button, edit):
    global subtitle
    subtitle = edit.edit_text
    raise urwid.ExitMainLoop()


def exit(button):
    global index
    index = None
    raise urwid.ExitMainLoop()


if len(movies) > 1:
    main = urwid.Padding(menu(u'Movie choice', movies), left=2, right=2)
else:
    selected_movie = movies[0]
    main = urwid.Padding(quick_start(u''), left=2, right=2)
    search(u'')

top = urwid.Overlay(main,
                    urwid.SolidFill(u'\N{MEDIUM SHADE}'),
                    align='center',
                    width=('relative', 60),
                    valign='middle',
                    height=('relative', 60),
                    min_width=20,
                    min_height=9)
urwid.MainLoop(top, palette=[('reversed', 'standout', '')]).run()
if index:
    makeGif(selected_movie['slug'], [index], custom_subtitle=[subtitle])
コード例 #8
0
CLIENT_ID = config.get("imgur", "client_id")
API_KEY = config.get("imgur", "api_key")
APP_KEY = config.get("twitter", "app_key")
APP_SECRET = config.get("twitter", "app_secret")
OAUTH_TOKEN = config.get("twitter", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("twitter", "oauth_token_secret")

headers = {"Authorization": "Client-ID " + CLIENT_ID}
url = "https://api.imgur.com/3/upload.json"

while True:
    while True:
        try:
            # you can set many more options, check the makeGif-function
            quote = makeGif(random.choice(slugs))
            quote = ' '.join(quote)
        except:
            print('something went wrong during gif-generation')
            continue
        else:
            break

    # first pass reduce the amount of colors
    if(os.path.getsize('star_wars.gif') > 5242880):
        subprocess.call(['convert',
                         'star_wars.gif',
                         '-layers',
                         'optimize',
                         '-colors',
                         '128',
コード例 #9
0
config.read("config.cfg")
config.sections()
slugs = check_config("config.cfg")[3]

APP_KEY = config.get("twitter", "app_key")
APP_SECRET = config.get("twitter", "app_secret")
OAUTH_TOKEN = config.get("twitter", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("twitter", "oauth_token_secret")

repeat = False

while repeat:
    while True:
        try:
            # you can set many more options, check the makeGif-function
            quote = makeGif(random.choice(slugs))
            quote = ' '.join(quote)
        except:
            print('something went wrong during gif-generation')
            continue
        else:
            break

    # first pass reduce the amount of colors
    if (os.path.getsize('barbarella.gif') > 5242880):
        subprocess.call([
            'convert', 'barbarella.gif', '-layers', 'optimize', '-colors',
            '128', '-loop', '0', 'barbarella.gif'
        ])

    # second pass reduce the amount of colors
コード例 #10
0
        link = res_json['data']['link']
    except ValueError:
        # try again.
        tweetGif(filename, quote)

    twitter = Twython(APP_KEY, APP_SECRET, OAUTH_TOKEN, OAUTH_TOKEN_SECRET)

    status = '"' + quote + '" ' + link + ' #randomgif'

    twitter.update_status(status=status)

if __name__ == '__main__':
    while True:
    	try:
    		choice = random.choice(choices)
    		quote = makeGif(choice, 0, rand=True)
    	except KeyboardInterrupt:
    		print "Ouch!"
    		exit()
    	except:
    		print "Unexpected error... trying again..."
    		print "tried to make gif from: " + str(choice)
    		continue

    	quote = ' '.join(quote)

    	print "tweeting..."
    	tweetGif('random.gif', quote)

    	print "sleeping..."
    	# sleep 1 hour
コード例 #11
0
CONSUMER_KEY = config.get("tumblr", "consumer_key")
CONSUMER_SECRET = config.get("tumblr", "consumer_secret")
OAUTH_TOKEN = config.get("tumblr", "oauth_token")
OAUTH_TOKEN_SECRET = config.get("tumblr", "oauth_token_secret")


t = Tumblpy(
	CONSUMER_KEY,
	CONSUMER_SECRET,
	OAUTH_TOKEN,
	OAUTH_TOKEN_SECRET,
)

while True:
	quote = makeGif(random.randint(4,6), 0, rand=True, frames=20)
	quote = ' '.join(quote)

	# reduce amount of colors, because tumblr sucks
	subprocess.call(['convert',
					'star_wars.gif',
					'-layers',
					'Optimize',
					'-colors',
					'64',
					'star_wars.gif'])
	while(os.path.getsize('star_wars.gif') > 1048576):
		subprocess.call(['convert',
						'star_wars.gif',
						'-resize',
						'90%',
コード例 #12
0
	body.append(urwid.AttrMap(no_button, None, focus_map='reversed'))
	main.original_widget = urwid.ListBox(urwid.SimpleFocusListWalker(body))

def enter_custom_subtitle(button):
	subtitle = urwid.Edit("Enter custom subtitle: ")
	done = urwid.Button(u'Submit')
	urwid.connect_signal(done, 'click', generate_gif_with_subtitle, subtitle)
	main.original_widget = urwid.Filler(urwid.Pile([subtitle,
		urwid.AttrMap(done, None, focus_map='reversed')]))

def generate_gif(button):
	raise urwid.ExitMainLoop()

def generate_gif_with_subtitle(button, edit):
	global subtitle
	subtitle = edit.edit_text
	raise urwid.ExitMainLoop()

def exit(button):
	index = None
	raise urwid.ExitMainLoop()

main = urwid.Padding(menu(u'Movie choice', choices), left=2, right=2)
top = urwid.Overlay(main, urwid.SolidFill(u'\N{MEDIUM SHADE}'),
	align='center', width=('relative', 60),
	valign='middle', height=('relative', 60),
	min_width=20, min_height=9)
urwid.MainLoop(top, palette=[('reversed', 'standout', '')]).run()
if index:
	makeGif(source, index, custom_subtitle=subtitle)
コード例 #13
0
    done = urwid.Button(u'Submit')
    urwid.connect_signal(done, 'click', generate_gif_with_subtitle, subtitle)
    main.original_widget = urwid.Filler(urwid.Pile([
        subtitle, urwid.AttrMap(done, None, focus_map='reversed')]))


def generate_gif(button):
    raise urwid.ExitMainLoop()


def generate_gif_with_subtitle(button, edit):
    global subtitle
    subtitle = edit.edit_text
    raise urwid.ExitMainLoop()


def exit(button):
    global index
    index = None
    raise urwid.ExitMainLoop()

main = urwid.Padding(menu(u'Movie choice', movies), left=2, right=2)
top = urwid.Overlay(main, urwid.SolidFill(
    u'\N{MEDIUM SHADE}'),
    align='center', width=('relative', 60),
    valign='middle', height=('relative', 60),
    min_width=20, min_height=9)
urwid.MainLoop(top, palette=[('reversed', 'standout', '')]).run()
if index:
    makeGif(selected_movie['slug'], [index], custom_subtitle=[subtitle])
コード例 #14
0
ファイル: movies.py プロジェクト: Alduhoo/starwars-dot-gif
	yes_button = urwid.Button("Yes")
	urwid.connect_signal(yes_button, 'click', enter_custom_subtitle)
	body.append(urwid.AttrMap(yes_button, None, focus_map='reversed'))
	no_button = urwid.Button("No")
	urwid.connect_signal(no_button, 'click', generate_gif)
	body.append(urwid.AttrMap(no_button, None, focus_map='reversed'))
	main.original_widget = urwid.ListBox(urwid.SimpleFocusListWalker(body))

def enter_custom_subtitle(button):
	subtitle = urwid.Edit("Enter custom subtitle: ")
	done = urwid.Button(u'Submit')
	urwid.connect_signal(done, 'click', generate_gif_with_subtitle, subtitle)
	main.original_widget = urwid.Filler(urwid.Pile([subtitle,
		urwid.AttrMap(done, None, focus_map='reversed')]))

def generate_gif(button):
	raise urwid.ExitMainLoop()

def generate_gif_with_subtitle(button, edit):
	global subtitle
	subtitle = edit.edit_text
	raise urwid.ExitMainLoop()

main = urwid.Padding(menu(u'Movie choice', choices), left=2, right=2)
top = urwid.Overlay(main, urwid.SolidFill(u'\N{MEDIUM SHADE}'),
	align='center', width=('relative', 60),
	valign='middle', height=('relative', 60),
	min_width=20, min_height=9)
urwid.MainLoop(top, palette=[('reversed', 'standout', '')]).run()
makeGif(choices[source], index, custom_subtitle=subtitle)
コード例 #15
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco

	# create a f****n' gif
	print "generating gif..."
	writeGif(filename, images, nq=10, dither=True)

	if rand:
		try:
			return text
		except:
			return []


if __name__ == '__main__':
	# by default we create a random gif
	makeGif(random.randint(4,6), 0, rand=True, no_quote=bool(random.getrandbits(1)))


########NEW FILE########
__FILENAME__ = star_wars_gif
#!/usr/bin/python

import urwid
import pysrt
from makeGifs import makeGif

choices = [ { 'name': "Star Wars: A New Hope", 'num': 4 },
			{ 'name': "Star Wars: The Empire Strikes Back", 'num': 5 },
			{ 'name': "Star Wars: Return of the Jedi", 'num': 6 } ]

sub_files = {   4: 'subs/IV-A.New.Hope[1977]DvDrip-aXXo.srt',