Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WordPress future post support #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion podpublish/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
5 changes: 4 additions & 1 deletion podpublish/publish_podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions podpublish/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down