diff --git a/README.md b/README.md index ee1f1a3..6961485 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ To upload a podcast. podpublish.publish-podcast ~/Syncthing/UbuntuPodcast/Configs/S11/s11exx.ini +To upload a podcast with a future date, set `wordpress.post_status` to `future` and... + + podpublish.publish-podcast --publishDate='1970-01-01 00:00:00' ~/Dropbox/UbuntuPodcast/Configs/S11/s11exx.ini + +(The format for `--publishDate` is `YYYY-MM-DD HH:mm:ss`) + ## TODO * Sanity check the number of tags before attempting a POST. 19 tags or fewer. diff --git a/podpublish/configuration.py b/podpublish/configuration.py index ffbe21a..e42dd32 100755 --- a/podpublish/configuration.py +++ b/podpublish/configuration.py @@ -20,10 +20,14 @@ def check_exists(file_in): class Configuration(object): - def __init__(self, ini_file): + def __init__(self, ini_file, args): # TODO: Use a ConfigSpec to validate the ini file. self.config = configobj.ConfigObj(ini_file) + # TODO: Validate date format + if self.config['wordpress']['post_status'] == 'future' and args['publishDate'] != "": + self.config['wordpress']['post_date'] = args['publishDate'] + # expand any relative file paths. if self.config['artwork']['backdrop'].startswith('~'): self.config['artwork']['backdrop'] = os.path.expanduser(self.config['artwork']['backdrop']) diff --git a/podpublish/publish_podcast.py b/podpublish/publish_podcast.py index 287b6a8..e555657 100755 --- a/podpublish/publish_podcast.py +++ b/podpublish/publish_podcast.py @@ -14,10 +14,13 @@ def main(): parser = argparse.ArgumentParser(description='Publish a podcast, previously encoded with encode_podcast, to sftp and YouTube.') parser.add_argument('--version', action='version', version=podpublish.__version__) + argparser.add_argument("--publishDate", default="", + help="Publish date for future WordPress posts. Format: YYYY-MM-DD HH:mm:ss") parser.add_argument('filename', type=argparse.FileType('r'), help="Podcast configuration file.") + args = parser.parse_args() - config = configuration.Configuration(args.filename) + config = configuration.Configuration(args.filename, args) if not config.skip_mp3 and not config.skip_sftp: if os.path.isfile(config.mp3_file): diff --git a/podpublish/uploader.py b/podpublish/uploader.py index 0e1f7ef..bdd7c23 100755 --- a/podpublish/uploader.py +++ b/podpublish/uploader.py @@ -121,6 +121,8 @@ def wordpress_post(config): post.comment_status = config.wordpress['comment_status'] if config.attach_header: post.thumbnail = attachment_id + if config.wordpress['post_format'] == 'future' and config.wordpress['post_date'] != '': + post.post_date = config.wordpress['post_date'] # FIXME: Make sure tags and category are defined. Don't assume they are. post.terms_names = {