mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-24 04:05:39 +01:00
Create NFO files with the extracted metadata. TVshows get a tvshow.nfo file as well.
This commit is contained in:
parent
184f79a377
commit
c15d7607eb
@ -15,6 +15,7 @@ from svtplay_dl.postprocess import postprocess
|
|||||||
from svtplay_dl.utils.stream import select_quality, list_quality
|
from svtplay_dl.utils.stream import select_quality, list_quality
|
||||||
from svtplay_dl.utils.text import exclude
|
from svtplay_dl.utils.text import exclude
|
||||||
from svtplay_dl.error import UIException
|
from svtplay_dl.error import UIException
|
||||||
|
from svtplay_dl.utils.nfo import write_nfo_episode, write_nfo_tvshow
|
||||||
|
|
||||||
|
|
||||||
def get_multiple_media(urls, config):
|
def get_multiple_media(urls, config):
|
||||||
@ -188,6 +189,11 @@ def get_one_media(stream):
|
|||||||
|
|
||||||
if fstream.config.get("thumbnail") and hasattr(stream, "get_thumbnail"):
|
if fstream.config.get("thumbnail") and hasattr(stream, "get_thumbnail"):
|
||||||
stream.get_thumbnail(stream.config)
|
stream.get_thumbnail(stream.config)
|
||||||
|
if stream.config.get("nfo"):
|
||||||
|
# Create NFO files
|
||||||
|
write_nfo_episode(stream.output, stream.config)
|
||||||
|
write_nfo_tvshow(stream.output, stream.config)
|
||||||
|
|
||||||
post = postprocess(fstream, fstream.config, subfixes)
|
post = postprocess(fstream, fstream.config, subfixes)
|
||||||
if fstream.audio and post.detect:
|
if fstream.audio and post.detect:
|
||||||
post.merge()
|
post.merge()
|
||||||
|
47
lib/svtplay_dl/utils/nfo.py
Normal file
47
lib/svtplay_dl/utils/nfo.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
|
from svtplay_dl.utils.output import formatname
|
||||||
|
from svtplay_dl.utils.parser import Options
|
||||||
|
|
||||||
|
|
||||||
|
def write_nfo_episode(output, config):
|
||||||
|
root = ET.Element("episodedetails")
|
||||||
|
ET.SubElement(root, "title").text = output["title_nice"]
|
||||||
|
ET.SubElement(root, "showtitle").text = output["episodename"]
|
||||||
|
ET.SubElement(root, "season").text = output["season"]
|
||||||
|
ET.SubElement(root, "episode").text = output["episode"]
|
||||||
|
ET.SubElement(root, "plot").text = output["showdescription"]
|
||||||
|
if not config.get("thumbnail"):
|
||||||
|
# Set the thumbnail path to download link if not thumbnail downloaded
|
||||||
|
ET.SubElement(root, "thumb").text = output["showthumbnailurl"]
|
||||||
|
|
||||||
|
filename = formatname(output.copy(), config, extension="nfo")
|
||||||
|
logging.info("NFO episode: %s", filename)
|
||||||
|
|
||||||
|
tree = ET.ElementTree(root)
|
||||||
|
tree.write(filename, encoding="UTF-8", xml_declaration=True)
|
||||||
|
|
||||||
|
|
||||||
|
def write_nfo_tvshow(output, config):
|
||||||
|
# Config for tvshow nfo file
|
||||||
|
root = ET.Element("tvshow")
|
||||||
|
ET.SubElement(root, "title").text = output["title_nice"]
|
||||||
|
ET.SubElement(root, "plot").text = output["episodedescription"]
|
||||||
|
if config.get("thumbnail"):
|
||||||
|
# Set the thumbnail relative path to downloaded thumbnail
|
||||||
|
ET.SubElement(root, "thumb").text = "{}.tvshow.tbn".format(output["title"])
|
||||||
|
else:
|
||||||
|
# Set the thumbnail path to download link if not thumbnail downloaded
|
||||||
|
ET.SubElement(root, "thumb").text = output["episodethumbnailurl"]
|
||||||
|
|
||||||
|
cconfig = Options()
|
||||||
|
cconfig.set("output", config.get("output"))
|
||||||
|
cconfig.set("path", config.get("path"))
|
||||||
|
cconfig.set("subfolder", config.get("subfolder"))
|
||||||
|
cconfig.set("filename", "tvshow.{ext}")
|
||||||
|
filename = formatname(output.copy(), cconfig, extension="nfo")
|
||||||
|
logging.info("NFO show: %s", filename)
|
||||||
|
|
||||||
|
tree = ET.ElementTree(root)
|
||||||
|
tree.write(filename, encoding="UTF-8", xml_declaration=True)
|
@ -92,6 +92,8 @@ def parser(version):
|
|||||||
"socks5://127.0.0.1:1080/.")
|
"socks5://127.0.0.1:1080/.")
|
||||||
general.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False,
|
general.add_argument("-v", "--verbose", action="store_true", dest="verbose", default=False,
|
||||||
help="explain what is going on")
|
help="explain what is going on")
|
||||||
|
general.add_argument("--nfo", action="store_true", dest="nfo", default=False,
|
||||||
|
help="create a NFO file")
|
||||||
|
|
||||||
quality = parser.add_argument_group("Quality")
|
quality = parser.add_argument_group("Quality")
|
||||||
quality.add_argument("-q", "--quality", default=0, metavar="quality",
|
quality.add_argument("-q", "--quality", default=0, metavar="quality",
|
||||||
@ -171,6 +173,7 @@ def setup_defaults():
|
|||||||
options.set("convert_subtitle_colors", False)
|
options.set("convert_subtitle_colors", False)
|
||||||
options.set("preferred", None)
|
options.set("preferred", None)
|
||||||
options.set("verbose", False)
|
options.set("verbose", False)
|
||||||
|
options.set("nfo", False)
|
||||||
options.set("output_auto", False)
|
options.set("output_auto", False)
|
||||||
options.set("service", None)
|
options.set("service", None)
|
||||||
options.set("cookies", None)
|
options.set("cookies", None)
|
||||||
@ -212,6 +215,7 @@ def parsertoconfig(config, parser):
|
|||||||
config.set("require_subtitle", parser.require_subtitle)
|
config.set("require_subtitle", parser.require_subtitle)
|
||||||
config.set("preferred", parser.preferred)
|
config.set("preferred", parser.preferred)
|
||||||
config.set("verbose", parser.verbose)
|
config.set("verbose", parser.verbose)
|
||||||
|
config.set("nfo", parser.nfo)
|
||||||
config.set("exclude", parser.exclude)
|
config.set("exclude", parser.exclude)
|
||||||
config.set("get_url", parser.get_url)
|
config.set("get_url", parser.get_url)
|
||||||
config.set("ssl_verify", parser.ssl_verify)
|
config.set("ssl_verify", parser.ssl_verify)
|
||||||
|
Loading…
Reference in New Issue
Block a user