-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmp3_to_xml.py
executable file
·41 lines (30 loc) · 1.7 KB
/
mp3_to_xml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import json
import datetime
import os
utils = __import__('utils')
def mp3_to_item(show, file):
print("Recovering the video's JSON file.")
path_show_file = show["general"]["name"] + "/" + file
utils.create_folder(path_show_file)
utils.get_metadatas(file, path_show_file)
today = str(datetime.datetime.today()).split(" ", 1)
today = today[0].replace("-", "")
pubdate = utils.get_pubdate(today, show["item"]["pub_date_hour"])
with open(path_show_file + "/" + file + ".json") as f:
json_data = json.load(f)
tags = json_data["format"]["tags"]
formats = json_data["format"]
show["item"]["title"] = tags["title"]
show["item"]["link"] = "WAITING_FOR_URL"
show["item"]["enclosure_url"] = show["item"]["enclosure_url"] + formats["filename"]
show["item"]["guid"] = show["item"]["guid"] + formats["filename"]
show["item"]["pub_date"] = pubdate
show["item"]["itunes_episode"] = tags["track"]
show["item"]["itunes_duration"] = utils.get_duration(float(formats["duration"]))
show["item"]["itunes_subtitle"] = tags["comment"]
show["item"]["itunes_description"] = tags["comment"]
show["item"]["content_encoded_main"] = tags["comment"]
item_text = utils.create_xml_item(show["item"], path_show_file + "/" + file + ".xml")
legacy_xml = utils.get_full_xml(show["general"]["main_xml_url"], path_show_file + "/" + today + "_" + show["general"]["name"])
utils.insert_item(item_text, path_show_file + "/" + today + "_" + show["general"]["name"] + "_LEGACY.xml", path_show_file + "/" + today + "_" + show["general"]["name"])
os.remove(path_show_file + "/" + file + ".json")