from os.path import dirname, splitext, basename, isfile
|
|
|
|
# TODO: We need some list (using enum?) for the commons licences, language, privacy, categories options
|
|
class Video(object):
|
|
"""Store data representing a Video."""
|
|
|
|
def __init__(self, path):
|
|
self.path = path
|
|
self.thumbnail = None
|
|
self.name = None
|
|
self.description = "default description"
|
|
self.playlistName = None
|
|
self.privacy = "private"
|
|
self.category = "films"
|
|
self.tags = []
|
|
self.language = "english"
|
|
self.originalDate = None # TODO: add a method "extract original date"? -> I feal that needs to be done outside of this class
|
|
|
|
# TODO: set as an object: { "all": date1, "platformX": date2, …}?
|
|
# Maybe the publishAt by platform is better placed in `self.platform`
|
|
# And so publishAt would only contains the global date.
|
|
self.publishAt = None
|
|
|
|
# TODO: Add a list of licences
|
|
self.licence = "proprietary"
|
|
self.disableComments = False
|
|
self.nsfw = False
|
|
|
|
# Each platform should insert here the upload state
|
|
# TODO: Create a platform object to have an common object/interface to use for each plugin?
|
|
self.platform = {}
|
|
|
|
@property
|
|
def thumbnail(self):
|
|
if not self._thumbnail is None:
|
|
return self._thumbnail
|
|
else:
|
|
result = None
|
|
video_directory = dirname(self.path) + "/"
|
|
|
|
# First, check for thumbnail based on videoname
|
|
if isfile(video_directory + self.name + ".jpg"):
|
|
result = video_directory + self.name + ".jpg"
|
|
elif isfile(video_directory + self.name + ".jpeg"):
|
|
result = video_directory + self.name + ".jpeg"
|
|
|
|
# Then, if we still not have thumbnail, check for thumbnail based on videofile name
|
|
# NOTE: This may be a the exact same check from the previous conditions if self._name = None.
|
|
# Bus as far as I know it is not recommended to use privates properties even in the same class
|
|
# Maybe check if self.name == splitext(basename(self.path))[0]
|
|
# Not done since it is early dev for the plugins rewrite
|
|
if not result:
|
|
video_file = splitext(basename(self.path))[0]
|
|
if isfile(video_directory + video_file + ".jpg"):
|
|
result = video_directory + video_file + ".jpg"
|
|
elif isfile(video_directory + video_file + ".jpeg"):
|
|
result = video_directory + video_file + ".jpeg"
|
|
|
|
# TODO: move to caller. Logging the output is its resporsability
|
|
# Display some info after research
|
|
# if not result:
|
|
# logger.debug("No thumbnail has been found, continuing")
|
|
# else:
|
|
# logger.info("Using " + result + " as thumbnail")
|
|
|
|
return result
|
|
|
|
@thumbnail.setter
|
|
def thumbnail(self, value):
|
|
self._thumbnail = value
|
|
|
|
@property
|
|
def name(self):
|
|
if not self._name is None:
|
|
return self._name
|
|
else:
|
|
return splitext(basename(self.path))[0]
|
|
|
|
@name.setter
|
|
def name(self, value):
|
|
self._name = value
|