Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/python3
- import sys
- import os
- import re
- from pathlib import Path
- info = []
- my_dir = "/path/to/your/tv/source/folder/"
- for item in Path(my_dir).glob('./*/tvshow.nfo'):
- M = str(item)
- show_attributes = []
- genre = []
- tags = []
- with open(M, "r") as f:
- for i in f:
- for j in re.findall("<title>(.+)</title>", i):
- show_attributes.append(j)
- for j in re.findall("<premiered>(.+)</premiered>", i):
- show_attributes.append(j)
- for j in re.findall("<rating>(.+)</rating>", i):
- show_attributes.append(j)
- for j in re.findall("<status>(.+)</status>", i):
- show_attributes.append(j)
- for j in re.findall("<studio>(.+)</studio>", i):
- show_attributes.append(j)
- with open(M, "r") as f:
- for i in f:
- for j in re.findall("<genre>(.+)</genre>", i):
- genre.append(j)
- show_attributes.append(', '.join(genre))
- with open(M, "r") as f:
- for i in f:
- for j in re.findall("<tag>(.+)</tag>", i):
- tags.append(j)
- show_attributes.append(', '.join(tags))
- info.append('_'.join(show_attributes))
- with open("output", "w") as w:
- for i in info:
- w.write(i + "\n")
- for i in info:
- print (i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement