|
@@ -257,7 +257,7 @@ doesnt, create it using the configuration class.
|
|
|
if os.access(os.environ['HOME'] + "/.stov", os.F_OK & os.W_OK) is not True:
|
|
|
logger.info(_("This seems to be the first time you run the programm, do "
|
|
|
"you want to run the interactive assistant? (yes/no)"))
|
|
|
- conf = configuration.conf()
|
|
|
+ conf = configuration.Conf()
|
|
|
if sys.version_info >= (3, 0):
|
|
|
temp_input = input()
|
|
|
else:
|
|
@@ -266,7 +266,7 @@ if os.access(os.environ['HOME'] + "/.stov", os.F_OK & os.W_OK) is not True:
|
|
|
if temp_input == "yes":
|
|
|
conf.assist()
|
|
|
try:
|
|
|
- conf.Initialize()
|
|
|
+ conf.initialize()
|
|
|
except stov_exceptions.ConfigFileWriteErrorException as e:
|
|
|
logger.error(e)
|
|
|
else:
|
|
@@ -278,19 +278,19 @@ if os.access(os.environ['HOME'] + "/.stov", os.F_OK & os.W_OK) is not True:
|
|
|
logger.debug(_("Creating hidden directory in home for configuration"
|
|
|
" and database."))
|
|
|
try:
|
|
|
- conf.Initialize()
|
|
|
+ conf.initialize()
|
|
|
except stov_exceptions.DirectoryCreationFailedException as e:
|
|
|
logger.error(e)
|
|
|
except stov_exceptions.ConfigFileWriteErrorException as e:
|
|
|
logger.error(e)
|
|
|
else:
|
|
|
- conf = configuration.conf()
|
|
|
+ conf = configuration.Conf()
|
|
|
if os.access(str(os.environ['HOME']) + "/.stov/stov.config", os.F_OK):
|
|
|
logger.debug(_("Migrating configuration from plain text to json."))
|
|
|
conf.migrate_config()
|
|
|
try:
|
|
|
logger.debug(_("Comparing current and running configuration version."))
|
|
|
- check_result = conf.CheckConfig()
|
|
|
+ check_result = conf.check_config()
|
|
|
except stov_exceptions.ConfigFileReadErrorException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -302,7 +302,7 @@ else:
|
|
|
logger.info(_("Your configuration needs to be updated, performing"
|
|
|
" update now."))
|
|
|
try:
|
|
|
- conf.UpdateConfig()
|
|
|
+ conf.update_config()
|
|
|
except stov_exceptions.ConfigFileReadErrorException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -315,19 +315,19 @@ else:
|
|
|
|
|
|
if os.access(conf.dbpath, os.F_OK):
|
|
|
try:
|
|
|
- db = database.db(path=conf.dbpath, version=conf.values["db_version"])
|
|
|
+ db = database.Db(path=conf.dbpath, version=conf.values["db_version"])
|
|
|
except stov_exceptions.DBConnectionFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
try:
|
|
|
- db = database.db(path=conf.dbpath, version=conf.values["db_version"])
|
|
|
+ db = database.Db(path=conf.dbpath, version=conf.values["db_version"])
|
|
|
except stov_exceptions.DBConnectionFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
try:
|
|
|
- db.Populate()
|
|
|
+ db.populate()
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -336,14 +336,14 @@ else:
|
|
|
|
|
|
try:
|
|
|
logger.debug(_("Comparing current and running database version."))
|
|
|
- if conf.CheckDB() is not True:
|
|
|
+ if conf.check_db() is not True:
|
|
|
logger.info(_("Your database needs to be updated, performing"
|
|
|
" update now."))
|
|
|
- db.Update()
|
|
|
- conf.values["db_version"] = db.GetVersion()
|
|
|
+ db.update()
|
|
|
+ conf.values["db_version"] = db.get_version()
|
|
|
logger.debug("Opening configuration file.")
|
|
|
try:
|
|
|
- conf.WriteConfig()
|
|
|
+ conf.write_config()
|
|
|
except stov_exceptions.ConfigFileWriteErrorException as e:
|
|
|
logger.error(e)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
@@ -371,7 +371,7 @@ if conf.values["youtube-dl"] == "":
|
|
|
"configuration file."))
|
|
|
logger.debug("Opening configuration file.")
|
|
|
try:
|
|
|
- conf.WriteConfig()
|
|
|
+ conf.write_config()
|
|
|
except stov_exceptions.ConfigFileWriteErrorException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -393,15 +393,15 @@ run the corresponding code
|
|
|
"""
|
|
|
if options.add is True:
|
|
|
if options.channel is not None and options.searchparameter is None:
|
|
|
- NewSubscription = subscription.sub(type="channel",
|
|
|
+ NewSubscription = subscription.Sub(subscription_type="channel",
|
|
|
name=options.channel, conf=conf)
|
|
|
elif options.channel is not None and options.searchparameter is not None:
|
|
|
- NewSubscription = subscription.sub(type="channel",
|
|
|
+ NewSubscription = subscription.Sub(subscription_type="channel",
|
|
|
name=options.channel,
|
|
|
search=options.searchparameter,
|
|
|
conf=conf)
|
|
|
elif options.channel is None and options.searchparameter is not None:
|
|
|
- NewSubscription = subscription.sub(type="search",
|
|
|
+ NewSubscription = subscription.Sub(subscription_type="search",
|
|
|
name=_("Search_"),
|
|
|
search=options.searchparameter,
|
|
|
conf=conf)
|
|
@@ -409,7 +409,7 @@ if options.add is True:
|
|
|
if options.searchparameter is not None:
|
|
|
logger.error(_("Playlists do not support searching, the search "
|
|
|
"option will be ignored!"))
|
|
|
- NewSubscription = subscription.sub(type="playlist",
|
|
|
+ NewSubscription = subscription.Sub(subscription_type="playlist",
|
|
|
name=options.playlist,
|
|
|
conf=conf)
|
|
|
else:
|
|
@@ -417,8 +417,8 @@ if options.add is True:
|
|
|
"the type option and try again."))
|
|
|
sys.exit(1)
|
|
|
try:
|
|
|
- id = db.InsertSubscription(NewSubscription.AddSub())
|
|
|
- NewSubscription.SetID(id)
|
|
|
+ id = db.insert_subscription(NewSubscription.add_sub())
|
|
|
+ NewSubscription.set_id(id)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -431,21 +431,21 @@ if options.add is True:
|
|
|
except stov_exceptions.NoDataFromYoutubeAPIException as e:
|
|
|
logger.error(e)
|
|
|
for video in NewSubscription.parsed_response.videos:
|
|
|
- if not db.VideoInDatabase(video.ytid):
|
|
|
- if NewSubscription.CheckStringMatch(video):
|
|
|
+ if not db.video_in_database(video.ytid):
|
|
|
+ if NewSubscription.check_string_match(video):
|
|
|
try:
|
|
|
- db.InsertVideo(video, NewSubscription.GetId())
|
|
|
+ db.insert_video(video, NewSubscription.get_id())
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
logger.debug(_("Video %s successfully inserted into "
|
|
|
"database.") % video.title)
|
|
|
- logger.info(_("New subscription ") + NewSubscription.GetTitle()
|
|
|
+ logger.info(_("New subscription ") + NewSubscription.get_title()
|
|
|
+ _(" successfully added"))
|
|
|
|
|
|
elif options.list is True:
|
|
|
- Listofsubscriptions = db.GetSubscriptions(conf)
|
|
|
+ Listofsubscriptions = db.get_subscriptions(conf)
|
|
|
sub_state = None
|
|
|
if len(Listofsubscriptions) != 0:
|
|
|
logger.info(_("ID Title"))
|
|
@@ -454,7 +454,7 @@ elif options.list is True:
|
|
|
sub_state = _("enabled")
|
|
|
elif sub.disabled:
|
|
|
sub_state = _("disabled")
|
|
|
- logger.info(str(sub.GetId()) + " " + sub.GetTitle()
|
|
|
+ logger.info(str(sub.get_id()) + " " + sub.get_title()
|
|
|
+ " (%s)" % sub_state)
|
|
|
else:
|
|
|
logger.info(_("No subscriptions added yet, add one!"))
|
|
@@ -467,7 +467,7 @@ elif options.deleteid is not None:
|
|
|
"option."))
|
|
|
else:
|
|
|
try:
|
|
|
- db.DeleteSubscription(DeleteID)
|
|
|
+ db.delete_subscription(DeleteID)
|
|
|
except stov_exceptions.SubscriptionNotFoundException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -477,10 +477,10 @@ elif options.deleteid is not None:
|
|
|
else:
|
|
|
logger.info(_("Subscription deleted successfully!"))
|
|
|
elif options.update is True:
|
|
|
- listofsubscriptions = db.GetSubscriptions(conf)
|
|
|
+ listofsubscriptions = db.get_subscriptions(conf)
|
|
|
for element in listofsubscriptions:
|
|
|
- videos = db.GetVideos(element.GetId(), conf)
|
|
|
- element.GatherVideos(videos)
|
|
|
+ videos = db.get_videos(element.get_id(), conf)
|
|
|
+ element.gather_videos(videos)
|
|
|
try:
|
|
|
element.update_data()
|
|
|
except stov_exceptions.YoutubeAPITimeoutException as e:
|
|
@@ -488,10 +488,10 @@ elif options.update is True:
|
|
|
except stov_exceptions.NoDataFromYoutubeAPIException as e:
|
|
|
logger.error(e)
|
|
|
for video in element.parsed_response.videos:
|
|
|
- if not db.VideoInDatabase(video.ytid):
|
|
|
- if element.CheckStringMatch(video):
|
|
|
+ if not db.video_in_database(video.ytid):
|
|
|
+ if element.check_string_match(video):
|
|
|
try:
|
|
|
- db.InsertVideo(video, element.GetId())
|
|
|
+ db.insert_video(video, element.get_id())
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -500,10 +500,10 @@ elif options.update is True:
|
|
|
"database.") % video.title)
|
|
|
|
|
|
elif options.download is True:
|
|
|
- listofsubscriptions = db.GetSubscriptions(conf)
|
|
|
+ listofsubscriptions = db.get_subscriptions(conf)
|
|
|
logger.debug(_("Trying to determine the itag value for youtube-dl from"
|
|
|
" your quality and codec settings."))
|
|
|
- itag_value = conf.GetYoutubeParameter()
|
|
|
+ itag_value = conf.get_youtube_parameter()
|
|
|
logger.debug(_("Found value: %s.") % itag_value)
|
|
|
if itag_value == 0:
|
|
|
logger.debug(_("Codec and resolution could not be determined, using "
|
|
@@ -512,22 +512,22 @@ elif options.download is True:
|
|
|
videosdownloaded = 0
|
|
|
videosfailed = 0
|
|
|
for element in listofsubscriptions:
|
|
|
- videos = db.GetVideos(element.GetId(), conf)
|
|
|
- element.GatherVideos(videos)
|
|
|
+ videos = db.get_videos(element.get_id(), conf)
|
|
|
+ element.gather_videos(videos)
|
|
|
try:
|
|
|
- element.DownloadVideos(itag_value)
|
|
|
+ element.download_videos(itag_value)
|
|
|
except stov_exceptions.SubscriptionDisabledException as e:
|
|
|
logger.debug(e)
|
|
|
- for entry in element.DownloadedVideos:
|
|
|
- db.UpdateVideoDownloadStatus(entry.GetID(), 1)
|
|
|
+ for entry in element.downloaded_videos:
|
|
|
+ db.update_video_download_status(entry.GetID(), 1)
|
|
|
mailcontent.append(entry.title)
|
|
|
videosdownloaded = len(mailcontent)
|
|
|
- videosfailed = videosfailed + element.FailedVideosCount
|
|
|
- for video in element.FailedVideos:
|
|
|
+ videosfailed = videosfailed + element.failed_videos_count
|
|
|
+ for video in element.failed_videos:
|
|
|
try:
|
|
|
- db.UpdateVideoFailCount(video.failcnt, video.GetID())
|
|
|
+ db.update_video_fail_count(video.failcnt, video.GetID())
|
|
|
if video.failcnt >= int(conf.values["maxfails"]):
|
|
|
- db.DisableFailedVideo(video.GetID())
|
|
|
+ db.disable_failed_video(video.GetID())
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -603,20 +603,20 @@ elif options.download is True:
|
|
|
|
|
|
elif options.subscriptionid is not None:
|
|
|
try:
|
|
|
- Data = db.GetSubscription(options.subscriptionid)
|
|
|
+ Data = db.get_subscription(options.subscriptionid)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
if Data:
|
|
|
- Subscription = subscription.sub(id=Data[0][0], title=Data[0][1],
|
|
|
- type=Data[0][2], name=Data[0][3],
|
|
|
+ Subscription = subscription.Sub(subscription_id=Data[0][0], title=Data[0][1],
|
|
|
+ subscription_type=Data[0][2], name=Data[0][3],
|
|
|
search=Data[0][4],
|
|
|
directory=Data[0][5],
|
|
|
disabled=Data[0][6], conf=conf)
|
|
|
- videos = db.GetVideos(Subscription.GetId(), conf)
|
|
|
- Subscription.GatherVideos(videos)
|
|
|
- video_list = Subscription.PrintVideos()
|
|
|
+ videos = db.get_videos(Subscription.get_id(), conf)
|
|
|
+ Subscription.gather_videos(videos)
|
|
|
+ video_list = Subscription.print_videos()
|
|
|
for video in video_list:
|
|
|
logger.info(video)
|
|
|
else:
|
|
@@ -624,14 +624,14 @@ elif options.subscriptionid is not None:
|
|
|
"try again."))
|
|
|
elif options.catchup is not None:
|
|
|
try:
|
|
|
- sub_data = db.GetSubscriptionTitle(options.catchup)
|
|
|
+ sub_data = db.get_subscription_title(options.catchup)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
else:
|
|
|
if sub_data != []:
|
|
|
try:
|
|
|
- db.MarkVideosDownloaded(options.catchup)
|
|
|
+ db.mark_video_downloaded(options.catchup)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
else:
|
|
@@ -640,32 +640,32 @@ elif options.catchup is not None:
|
|
|
|
|
|
|
|
|
elif options.cleanup is True:
|
|
|
- subscriptions_list = db.GetSubscriptions(conf)
|
|
|
+ subscriptions_list = db.get_subscriptions(conf)
|
|
|
for element in subscriptions_list:
|
|
|
- videos = db.GetVideos(element.GetId(), conf)
|
|
|
- element.CheckAndDelete(videos)
|
|
|
+ videos = db.get_videos(element.get_id(), conf)
|
|
|
+ element.check_and_delete(videos)
|
|
|
for delete_video in element.ToDelete:
|
|
|
logger.debug(_("Deleting video %s from "
|
|
|
"database") % delete_video.title)
|
|
|
try:
|
|
|
- db.DeleteVideo(delete_video.GetID())
|
|
|
+ db.delete_video(delete_video.GetID())
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
try:
|
|
|
- db.Vacuum()
|
|
|
+ db.vacuum()
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
|
elif options.enableid is not None:
|
|
|
- subscription_state = db.GetSubscription(options.enableid)
|
|
|
+ subscription_state = db.get_subscription(options.enableid)
|
|
|
try:
|
|
|
if int(subscription_state[0][6]) == 0:
|
|
|
logger.error(_("The subscription ID %s is already enabled.")
|
|
|
% options.enableid)
|
|
|
elif int(subscription_state[0][6]) == 1:
|
|
|
try:
|
|
|
- db.ChangeSubscriptionState(options.enableid, 0)
|
|
|
+ db.change_subscription_state(options.enableid, 0)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|
|
@@ -676,14 +676,14 @@ elif options.enableid is not None:
|
|
|
logger.error(_("Could not find the subscription with ID %s, "
|
|
|
"please check and try again.") % options.enableid)
|
|
|
elif options.disableid is not None:
|
|
|
- subscription_state = db.GetSubscription(options.disableid)
|
|
|
+ subscription_state = db.get_subscription(options.disableid)
|
|
|
try:
|
|
|
if int(subscription_state[0][6]) == 1:
|
|
|
logger.error(_("Subscription ID %s is already disabled.")
|
|
|
% options.disableid)
|
|
|
elif int(subscription_state[0][6]) == 0:
|
|
|
try:
|
|
|
- db.ChangeSubscriptionState(options.disableid, 1)
|
|
|
+ db.change_subscription_state(options.disableid, 1)
|
|
|
except stov_exceptions.DBWriteAccessFailedException as e:
|
|
|
logger.error(e)
|
|
|
sys.exit(1)
|