Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- from sys import stdin, stderr, argv
- import re
- if argv[1]=='-h':
- print "%s <ytc-file> > <cue-file>" % (argv[0])
- exit(0)
- if len(argv) == 2 and not argv[1]=='-':
- import io
- stdin = io.open(argv[1], 'rt')
- header_tpl = """PERFORMER "%s"
- TITLE "%s"
- """
- track_tpl = """ TRACK %02d AUDIO
- TITLE "%s"
- PERFORMER "%s"
- INDEX 01 %02d:%02d:00
- """
- curr_idx = 0
- interpret = stdin.readline().strip()
- print header_tpl % (interpret, stdin.readline().strip(), )
- if len(stdin.readline().strip()) != 0:
- stderr.write("Missing Blank line\n")
- exit(1)
- rgx = re.compile('^(\d{1,2}):(\d{1,2}) (.+)$')
- for line in stdin.readlines():
- line = line.strip()
- if len(line)==0:
- break
- foo, start_min, start_sec, title, bar = rgx.split(line)
- curr_idx = curr_idx + 1
- print track_tpl % (curr_idx, title, interpret, int(start_min), int(start_sec))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement