Gets a random post from a subreddit and returns a title and shortlink to it.
185133
def random_post(subreddit, apikey):
    """"""
    subreddit = '/r/random' if subreddit is None else '/r/%s' % subreddit
    urlstr = 'http://reddit.com%s/random?%s' % (subreddit, time.time())
    url = get(urlstr, headers={'User-Agent': 'CslBot/1.0'}).url
    return '** %s - %s' % (get_title(url, apikey), get_short(url, apikey))
1207900
def from_shortcode(cls, context: InstaloaderContext, shortcode: str):
        """"""
        # pylint:disable=protected-access
        post = cls(context, {'shortcode': shortcode})
        post._node = post._full_metadata
        return post
850605
def get_link(self, text=None, *args, **kwargs):
        
        return helpers.find(
            self.parsed, _link_ptn, text=text, *args, **kwargs
        )
110347
function fetchPosts({state, actions, opts: {api}}, reddit) {
	let posts = state.postsByReddit[reddit]

	if (_shouldFetchPosts(posts)) {
		api.fetchPosts(reddit)
			.then(json => actions.postsFetched(reddit, json))

		return {
			...state,
			postsByReddit: {
				...state.postsByReddit,
				[reddit]: Object.assign({}, posts, {
					isFetching: true, 
					didInvalidate: false, 
					posts: []
				})
			}
		}

	}

	return state
}
800397
def open_link(self):
        

        data = self.get_selected_item()
        if data['url_type'] == 'selfpost':
            self.open_submission()
        elif data['url_type'] == 'x-post subreddit':
            self.refresh_content(order='ignore', name=data['xpost_subreddit'])
        elif data['url_type'] == 'x-post submission':
            self.open_submission(url=data['url_full'])
            self.config.history.add(data['url_full'])
        else:
            self.term.open_link(data['url_full'])
            self.config.history.add(data['url_full'])
859026
function getPost(post) {
  if (!post || !post.body) return {};


  let postQuery = getPostQuery(post.body);
  let postIntro = postQuery.intro || getPostIntro(post.body);

  Object.assign(post, {
    intro: postIntro,
    query: postQuery,
    create_time: formatTime(post.created_at),
    update_time: formatTime(post.updated_at)
  })

  return post;
}
1148627
public function iVisitTheBlogPostPage($title)
    {
        $post = $this->findPostByTitle($title);
        $url = '/'.$post['post_name'];

        return new Then(sprintf('I go to "%s"', $url));
    }
1108195
def get_short_url(self):
        
        return reverse('post_short_url', args=(self.forum.slug, self.slug, self.id))
858386
def cmd(send, msg, args):
    
    if msg and not check_exists(msg):
        send("Non-existant subreddit.")
        return
    subreddit = msg if msg else None
    send(random_post(subreddit, args['config']['api']['bitlykey']))
790891
def get_select_title_url(self, attach=None):
        
        return self._post(
            'biz/getselecttitleurl',
            data={
                'attach': attach,
            },
            result_processor=lambda x: x['url'],
        )
67552
def get_wiki_page(self, subreddit, page):
        """"""
        return objects.WikiPage(self, six.text_type(subreddit), page.lower())
56359
def randtld(self):
        
        self.tlds = tuple(tlds.tlds) if not self.tlds else self.tlds
        return self.random.choice(self.tlds)
23250
def get_new_subreddits(self, *args, **kwargs):
        
        url = self.config['new_subreddits']
        return self.get_content(url, *args, **kwargs)
948108
def get_random_subreddit(self, nsfw=False):
        
        path = 'random'
        if nsfw:
            self.http.cookies.set('over18', '1')
            path = 'randnsfw'
        url = self.config['subreddit'].format(subreddit=path)
        response = self._request(url, params={'unique': self._unique_count},
                                 raw_response=True)
        self._unique_count += 1
        return self.get_subreddit(response.url.rsplit('/', 2)[-2])
564877
def from_api_response(cls, reddit_session, json_dict):
        """"""
        # The Multireddit response contains the Subreddits attribute as a list
        # of dicts of the form {'name': 'subredditname'}.
        # We must convert each of these into a Subreddit object.
        json_dict['subreddits'] = [Subreddit(reddit_session, item['name'])
                                   for item in json_dict['subreddits']]
        return cls(reddit_session, None, None, json_dict)
467164
def post(url: str, *args, **kwargs) -> tuple:
    """"""
    return RequestsHelper.request(url, "post", *args, **kwargs)
346946
def post_submission(self):
        
        # Check that the subreddit can be submitted to
        name = self.content.name
        if '+' in name or name in ('/r/all', '/r/front', '/r/me', '/u/saved'):
            self.term.show_notification("Can't post to {0}".format(name))
            return

        submission_info = docs.SUBMISSION_FILE.format(name=name)
        with self.term.open_editor(submission_info) as text:
            if not text:
                self.term.show_notification('Canceled')
                return
            elif '\n' not in text:
                self.term.show_notification('Missing body')
                return

            title, content = text.split('\n', 1)
            with self.term.loader('Posting', delay=0):
                submission = self.reddit.submit(name, title, text=content,
                                                raise_captcha_exception=True)
                # Give reddit time to process the submission
                time.sleep(2.0)
            if self.term.loader.exception:
                raise TemporaryFileError()

        if not self.term.loader.exception:
            # Open the newly created submission
            self.selected_page = self.open_submission_page(submission=submission)