Fetches the latest media added to MAL.

    :type session: :class:`myanimelist.session.Session`
    :param session: A valid MAL session

    :rtype: :class:`.Media`
    :return: the newest media on MAL

    :raises: :class:`.MalformedMediaPageError`
771613
def newest(cls, session):
    
    media_type = cls.__name__.lower()
    p = session.session.get(u'http://myanimelist.net/' + media_type + '.php?o=9&c[]=a&c[]=d&cv=2&w=1').text
    soup = utilities.get_clean_dom(p)
    latest_entry = soup.find(u"div", {u"class": u"hoverinfo"})
    if not latest_entry:
      raise MalformedMediaPageError(0, p, u"No media entries found on recently-added page")
    latest_id = int(latest_entry[u'rel'][1:])
    return getattr(session, media_type)(latest_id)
1362222
def get_locals(cls, session):
        
        return cls.find(session,
                        where=(cls.local == True,))
1292635
def sessions(session):
    
    active_sessions = session.get_sessions()
    if not active_sessions:
        click.echo('(No active sessions)')
        return
    for active_session in active_sessions:
        click.echo(active_session)
1023634
def load(self):
    
    user_profile = self.session.session.get(u'http://myanimelist.net/profile/' + utilities.urlencode(self.username)).text
    self.set(self.parse(utilities.get_clean_dom(user_profile)))
    return self
329837
def get_new_session(self):
        """"""
        session = Session()
        session.headers = self.headers
        session.proxies = self._get_request_proxies()
        return session
696776
def retrieve_page(rurl = nil)
      durl = rurl || url
      return nil unless durl
      durl = filter_url(durl) if self.respond_to?(:filter_url)
      self.class.retrieve_session ||= WebPageParser::HTTP::Session.new
      encode(self.class.retrieve_session.get(durl))
    end
124891
def query(self):
        """"""

        return self._session.query(Process).filter(Process.d_vid == self._d_vid)
627101
def medias(self, timeframe=None):
        
        info = self.info
        if timeframe is not None:
            start, end = TimedMediasIterator.get_times(timeframe)
            timestamp = info.get("taken_at_timestamp") or info["media"]
            if not (start >= timestamp >= end):
                raise StopIteration
        yield info
944957
def download(self, media_id, as_stream=False):
        
        response = self.__app.native_api_call('media', 'd/' + media_id, {}, self.__options, False, None, as_stream, http_path="/api/meta/v1/", http_method='GET')
        return response
1023002
def session(self):
        """"""
        if self._session is None:
            self._session = cachecontrol.CacheControl(
                requests.Session(),
                cache=caches.FileCache('.tvdb_cache'))
        return self._session
159029
def get_media_list(self, media_type, offset, count):
        
        return self.post(
            url="https://api.weixin.qq.com/cgi-bin/material/batchget_material",
            data={
                "type": media_type,
                "offset": offset,
                "count": count
            }
        )
1117503
def getReadSession(self):
        '''  '''
        if self.ReadSession is None:
            self.ReadSession=scoped_session(sessionmaker(bind=self.engine))

        return self.ReadSession
813173
def _get_content(cls, url, headers=HTTP_HEADERS):
        
        session = requests.Session()
        return session.get(url, headers=headers)
939920
def get_page_and_url(session, url):
    
    reply = get_reply(session, url)
    return reply.text, reply.url
233818
def captcha_refresh(request):
    
    if not request.is_ajax():
        raise Http404

    new_key = CaptchaStore.pick()
    to_json_response = {
        'key': new_key,
        'image_url': captcha_image_url(new_key),
        'audio_url': captcha_audio_url(new_key) if settings.CAPTCHA_FLITE_PATH else None
    }
    return HttpResponse(json.dumps(to_json_response), content_type='application/json')
1215539
def _media(self):
        
        def static_url(url):
            return staticfiles_storage.url('zinnia_markitup/%s' % url)

        media = super(EntryAdminMarkItUpMixin, self).media

        media += Media(
            js=(static_url('js/jquery.min.js'),
                static_url('js/markitup/jquery.markitup.js'),
                static_url('js/markitup/sets/%s/set.js' % (
                    settings.MARKUP_LANGUAGE)),
                reverse('admin:zinnia_entry_markitup')),
            css={'all': (
                static_url('js/markitup/skins/django/style.css'),
                static_url('js/markitup/sets/%s/style.css' % (
                    settings.MARKUP_LANGUAGE)))}
        )
        return media
419419
def _fetch_new(&client_block)
      if (@never_block || (_total_current_size < @max_size))
        if client_block.arity == 0
          nc = yield
        else
          nc = yield @sessions_key
        end
        HotTub.logger.info "[HotTub] Adding client: #{nc.class.name} to #{@name}." if HotTub.log_trace?
        nc
      end
    end