Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from sys import stdin, stderr, argv
  4. import re
  5.  
  6. if argv[1]=='-h':
  7. print "%s <ytc-file> > <cue-file>" % (argv[0])
  8. exit(0)
  9.  
  10. if len(argv) == 2 and not argv[1]=='-':
  11. import io
  12. stdin = io.open(argv[1], 'rt')
  13.  
  14. header_tpl = """PERFORMER "%s"
  15. TITLE "%s"
  16. """
  17.  
  18. track_tpl = """ TRACK %02d AUDIO
  19. TITLE "%s"
  20. PERFORMER "%s"
  21. INDEX 01 %02d:%02d:00
  22. """
  23.  
  24. curr_idx = 0
  25. interpret = stdin.readline().strip()
  26.  
  27. print header_tpl % (interpret, stdin.readline().strip(), )
  28.  
  29. if len(stdin.readline().strip()) != 0:
  30. stderr.write("Missing Blank line\n")
  31. exit(1)
  32.  
  33.  
  34. rgx = re.compile('^(\d{1,2}):(\d{1,2}) (.+)$')
  35.  
  36. for line in stdin.readlines():
  37. line = line.strip()
  38. if len(line)==0:
  39. break
  40. foo, start_min, start_sec, title, bar = rgx.split(line)
  41. curr_idx = curr_idx + 1
  42. print track_tpl % (curr_idx, title, interpret, int(start_min), int(start_sec))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement