diff --git a/edit.py b/edit.py index 973c20b..9cb8f9a 100755 --- a/edit.py +++ b/edit.py @@ -95,12 +95,12 @@ def sort_clips(edit, sort): def get_pandora_media_path(oshash): h = oshash - path = '/srv/pandora/data/media/' + '/'.join([h[:2], h[2:4], h[4:6], h[6:]]) - path = glob('%s/data.*' % path) + prefix = '/srv/pandora/data/media/' + '/'.join([h[:2], h[2:4], h[4:6], h[6:]]) + path = glob('%s/data.*' % prefix) if path: path = path[0] else: - path = ox.sorted_strings(glob('%s/*.mp4' % path))[-1] + path = ox.sorted_strings(glob('%s/*.mp4' % prefix))[-1] return path def cache_clips(api, videos, use_source=False, use_pandora=False): @@ -127,7 +127,7 @@ def cache_clips(api, videos, use_source=False, use_pandora=False): print(url, out) api.save_url(url, out) -def make_title(title): +def make_title(title, font_size=30): from PIL import Image, ImageFont, ImageDraw title_mp4 = "cache/title_%s.mp4" % hashlib.sha1(title.encode()).hexdigest() title_png = title_mp4.replace('.mp4', '.png') @@ -135,7 +135,7 @@ def make_title(title): width = 852 height = 480 image = Image.new("RGB", (width, height), "black") - font = ImageFont.truetype("/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Bold.ttf", size=30) + font = ImageFont.truetype("/usr/share/fonts/truetype/roboto/unhinted/RobotoTTF/Roboto-Bold.ttf", size=font_size) draw = ImageDraw.Draw(image) _, _, font_width, font_height = font.getbbox(title) new_width = (width - font_width) / 2 @@ -174,6 +174,8 @@ if __name__ == '__main__': help="resolution of streams to download i.e. 480, 240, 96 default 480", default=480) parser.add_argument('-t', '--title', dest='title', type=str, help="title", default="") + parser.add_argument('', '--font-size', dest='font_size', type=int, + help="title font size", default=30) parser.add_argument('-c', '--config', dest='config', help='config.json containing config', default='~/.ox/client.json') @@ -241,7 +243,7 @@ if __name__ == '__main__': position = 0 clips = sort_clips(edit, sort_by) if opts.title: - clips.insert(0, make_title(opts.title)) + clips.insert(0, make_title(opts.title, opts.font_size)) for clip in clips: if clip.get("titletext"): videos.append(clip)