Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #! /usr/bin/python3
  2.  
  3. import sys
  4. import os
  5. import re
  6. from pathlib import Path
  7.  
  8. info = []
  9. my_dir = "/path/to/your/tv/source/folder/"
  10. for item in Path(my_dir).glob('./*/tvshow.nfo'):
  11. M = str(item)
  12. show_attributes = []
  13. genre = []
  14. tags = []
  15. with open(M, "r") as f:
  16. for i in f:
  17. for j in re.findall("<title>(.+)</title>", i):
  18. show_attributes.append(j)
  19. for j in re.findall("<premiered>(.+)</premiered>", i):
  20. show_attributes.append(j)
  21. for j in re.findall("<rating>(.+)</rating>", i):
  22. show_attributes.append(j)
  23. for j in re.findall("<status>(.+)</status>", i):
  24. show_attributes.append(j)
  25. for j in re.findall("<studio>(.+)</studio>", i):
  26. show_attributes.append(j)
  27.  
  28. with open(M, "r") as f:
  29. for i in f:
  30. for j in re.findall("<genre>(.+)</genre>", i):
  31. genre.append(j)
  32. show_attributes.append(', '.join(genre))
  33.  
  34. with open(M, "r") as f:
  35. for i in f:
  36. for j in re.findall("<tag>(.+)</tag>", i):
  37. tags.append(j)
  38. show_attributes.append(', '.join(tags))
  39.  
  40. info.append('_'.join(show_attributes))
  41. with open("output", "w") as w:
  42. for i in info:
  43. w.write(i + "\n")
  44. for i in info:
  45. print (i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement