def make_posts(generator, metadata, url):
    """
    Make posts on reddit if it's not a draft, on whatever subs are specified
    """
    reddit = generator.get_reddit()
    title =  lxml.html.fromstring(metadata['title']).text_content()
    if reddit is None:
        log.info("Reddit plugin not enabled")
        return
    if metadata.get('status') == "draft": # people don't want to post drafts
        log.debug("ignoring draft %s" % title)
        return

    collection = generator.settings['REDDIT_POSTER_COLLECT_SUB']
    sub = reddit.subreddit(collection)
    results = sub.search(title)
    if len([result for result in results]) > 0:
        log.debug("ignoring %s because it is already on sub %s " % (title, collection))
        # post already was made to this sub
        return
    try:
        submission = sub.submit(title, url=url, resubmit=False)
        cross_post(reddit, submission, metadata.get('subreddit'))
    except praw.exceptions.APIException as e:
        log.error("got an api exception: %s", e)
    except AssertionError as e:
        log.error("Received an assertion error %s", e)
def make_posts ( generator , metadata , url ) : reddit = generator . get_reddit ( ) title = lxml . html . fromstring ( metadata [ 'title' ] ) . text_content ( ) if reddit is None : log . info ( "Reddit plugin not enabled" ) return if metadata . get ( 'status' ) == "draft" : log . debug ( "ignoring draft %s" % title ) return collection = generator . settings [ 'REDDIT_POSTER_COLLECT_SUB' ] sub = reddit . subreddit ( collection ) results = sub . search ( title ) if len ( [ result for result in results ] ) > 0 : log . debug ( "ignoring %s because it is already on sub %s " % ( title , collection ) ) return try : submission = sub . submit ( title , url = url , resubmit = False ) cross_post ( reddit , submission , metadata . get ( 'subreddit' ) ) except praw . exceptions . APIException as e : log . error ( "got an api exception: %s" , e ) except AssertionError as e : log . error ( "Received an assertion error %s" , e )
Make posts on reddit if it's not a draft, on whatever subs are specified