/
upload_to_posterous.py
executable file
·49 lines (36 loc) · 1.11 KB
/
upload_to_posterous.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
''' This script posts a video to Posterous site
'''
import os
import sys
from datetime import datetime
from subprocess import call
import urlparse
from logbook import debug, info, warn, error, critical
from configobj import ConfigObj
import settings
import utils
import posterous
config = ConfigObj(settings.posterous_config, write_empty_values=True)
def items_to_upload():
for item in config:
if not config[item].get('processed'):
yield item
def mark_as_processed(item, post_id):
debug("Updating config for " + item)
config.reload()
config[item]['processed'] = 1
config[item]['post id'] = post_id
config[item]['posted on'] = str(datetime.now())
config.write()
def main():
for item in items_to_upload():
debug('=' * 60)
filename = utils.download(item)
post_id = posterous.post(title=config[item]['title'],
tags=config[item]['tags'],
media=filename)
mark_as_processed(item, post_id)
if __name__ == "__main__":
utils.start_logging(__file__)
main()