Advertisement
micycle

Total time elapsed upto each track (music album formatting)

Apr 29th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. times = ("""1:48
  2. 3:52
  3. 3:28
  4. 3:38
  5. 3:24
  6. 2:50
  7. 2:57
  8. 0:44
  9. 4:55
  10. 4:18
  11. 4:02
  12. 5:11
  13. 3:27""")
  14.  
  15. tracks = ("""L’introduction
  16. Hamburg
  17. All Day Long
  18. Affair
  19. Human Touch (feat. Maya Vik)
  20. Jørgens Lille Skit
  21. Imagination
  22. Sjølie Skit
  23. How Low Can You Go
  24. Save Us
  25. All Night Long
  26. Way It Should
  27. Oktober""")
  28.  
  29. import datetime
  30.  
  31. total = datetime.timedelta(minutes = 0,seconds = 0)
  32.  
  33. for item in enumerate(zip(times.split("\n"),tracks.split("\n"))):
  34.     print(str(item[0]).zfill(2)+".",item[1][1],"("+str(total)[2:]+")") # [2:] mm:ss only, delete for hh:mm:ss
  35.     mins = datetime.timedelta(minutes = int(item[1][0].split(":")[1][0]))
  36.     secs = datetime.timedelta(seconds = int(item[1][0].split(":")[1][1]))
  37.     total += (mins+secs)
  38.  
  39. """
  40. Output:
  41. 00. L’introduction (00:00)
  42. 01. Hamburg (04:08)
  43. 02. All Day Long (09:10)
  44. 03. Affair (11:18)
  45. 04. Human Touch (feat. Maya Vik) (14:26)
  46. 05. Jørgens Lille Skit (16:30)
  47. 06. Imagination (21:30)
  48. 07. Sjølie Skit (26:37)
  49. 08. How Low Can You Go (30:41)
  50. 09. Save Us (35:46)
  51. 10. All Night Long (36:54)
  52. 11. Way It Should (36:56)
  53. 12. Oktober (37:57)
  54.  
  55. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement