Parses the DOM and returns media attributes in the main-content area.

    :type media_page: :class:`bs4.BeautifulSoup`
    :param media_page: MAL media page's DOM

    :rtype: dict
    :return: media attributes.
197384
def parse(self, media_page):
    
    media_info = self.parse_sidebar(media_page)

    try:
      synopsis_elt = media_page.find(u'h2', text=u'Synopsis').parent
      utilities.extract_tags(synopsis_elt.find_all(u'h2'))
      media_info[u'synopsis'] = synopsis_elt.text.strip()
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    try:
      related_title = media_page.find(u'h2', text=u'Related ' + self.__class__.__name__)
      if related_title:
        related_elt = related_title.parent
        utilities.extract_tags(related_elt.find_all(u'h2'))
        related = {}
        for link in related_elt.find_all(u'a'):
          href = link.get(u'href').replace(u'http://myanimelist.net', '')
          if not re.match(r'/(anime|manga)', href):
            break
          curr_elt = link.previous_sibling
          if curr_elt is None:
            # we've reached the end of the list.
            break
          related_type = None
          while True:
            if not curr_elt:
              raise MalformedAnimePageError(self.id, related_elt, message="Prematurely reached end of related anime listing")
            if isinstance(curr_elt, bs4.NavigableString):
              type_match = re.match(u'(?P<type>[a-zA-Z\ \-]+):', curr_elt)
              if type_match:
                related_type = type_match.group(u'type')
                break
            curr_elt = curr_elt.previous_sibling
          title = link.text
          # parse link: may be manga or anime.
          href_parts = href.split(u'/')
          # sometimes links on MAL are broken, of the form /anime//
          if href_parts[2] == '':
            continue
          # of the form: /(anime|manga)/1/Cowboy_Bebop
          obj_id = int(href_parts[2])
          new_obj = getattr(self.session, href_parts[1])(obj_id).set({'title': title})
          if related_type not in related:
            related[related_type] = [new_obj]
          else:
            related[related_type].append(new_obj)
        media_info[u'related'] = related
      else:
        media_info[u'related'] = None
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    return media_info
894847
def get_small_image_url(self, page=1):
        
        template = self.resources.page.get('image')
        return template.replace(
            "{page}",
            str(page)
        ).replace("{size}", "small")
350591
def get_or_add_media_part(self, media):
        
        media_part = self._find_by_sha1(media.sha1)
        if media_part is None:
            media_part = MediaPart.new(self._package, media)
        return media_part
1130123
def media(self):
        
        media = self._get_common_media()
        media += self._get_view_media()
        media += self.get_media_assets()
        return media
552278
function parsePage(book, page) {
    var fs = book.getContentFS();
    var file = page.getFile();

    return fs.readAsString(file.getPath())
    .then(function(content) {
        return parsePageFromString(page, content);
    });
}
822796
def page_from_file(input_file):
    
    #  print("PARSING PARSING '%s'" % input_file)
    if input_file.mimetype.startswith('image'):
        return page_from_image(input_file)
    if input_file.mimetype == MIMETYPE_PAGE:
        return parse(input_file.local_filename, silence=True)
    raise Exception("Unsupported mimetype '%s'" % input_file.mimetype)
1044476
def parse_entry_media_attributes(self, soup):
    
    row_info = {}

    try:
      start = utilities.parse_profile_date(soup.find('series_start').text)
    except ValueError:
      start = None
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    if start is not None:
      try:
        row_info['aired'] = (start, utilities.parse_profile_date(soup.find('series_end').text))
      except ValueError:
        row_info['aired'] = (start, None)
      except:
        if not self.session.suppress_parse_exceptions:
          raise

    # look up the given media type's status terms.
    status_terms = getattr(self.session, self.type)(1)._status_terms

    try:
      row_info['id'] = int(soup.find('series_' + self.type + 'db_id').text)
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    try:
      row_info['title'] = soup.find('series_title').text
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    try:
      row_info['status'] = status_terms[int(soup.find('series_status').text)]
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    try:
      row_info['picture'] = soup.find('series_image').text
    except:
      if not self.session.suppress_parse_exceptions:
        raise

    return row_info
60115
def _get_page_title(self, page):
        
        fname = os.path.join(SOURCE_PATH, '{}.rst'.format(page))
        option_parser = docutils.frontend.OptionParser(
            components=(docutils.parsers.rst.Parser,))
        doc = docutils.utils.new_document(
            '<doc>',
            option_parser.get_default_values())
        with open(fname) as f:
            data = f.read()

        parser = docutils.parsers.rst.Parser()
        # do not generate any warning when parsing the rst
        with open(os.devnull, 'a') as f:
            doc.reporter.stream = f
            parser.parse(data, doc)

        section = next(node for node in doc.children
                       if isinstance(node, docutils.nodes.section))
        title = next(node for node in section.children
                     if isinstance(node, docutils.nodes.title))

        return title.astext()
128325
def get_image_list(self, page=1, per_page=20):
        
        url = self.api_url + '/api/images'
        params = {
            'page': page,
            'per_page': per_page
        }
        response = self._request_url(
            url, 'get', params=params, with_access_token=True)
        headers, result = self._parse_and_check(response)
        images = ImageList.from_list(result)
        images.set_attributes_from_headers(headers)
        return images
935287
def html(self, page, version=None):
        
        return (self._dokuwiki.send('wiki.getPageHTMLVersion', page, version)
                if version is not None
                else self._dokuwiki.send('wiki.getPageHTML', page))
932880
function(media) {
    if (typeof media === "undefined") {
      // If left blank, all media on the page will be polyfilled.
      media = document.querySelectorAll("[data-object-fit]");
    } else if (media && media.nodeName) {
      // If it's a single node, wrap it in an array so it works.
      media = [media];
    } else if (typeof media === "object" && media.length && media[0].nodeName) {
      // If it's an array of DOM nodes (e.g. a jQuery selector), it's fine as-is.
      media = media;
    } else {
      // Otherwise, if it's invalid or an incorrect type, return false to let people know.
      return false;
    }

    for (var i = 0; i < media.length; i++) {
      if (!media[i].nodeName) { continue; }

      var mediaType = media[i].nodeName.toLowerCase();

      if (mediaType === "img" && !edgePartialSupport) {
        if (media[i].complete) {
          objectFit(media[i]);
        }
        else {
          media[i].addEventListener("load", function() {
            objectFit(this);
          });
        }
      }
      else if (mediaType === "video") {
        if (media[i].readyState > 0) {
          objectFit(media[i]);
        }
        else {
          media[i].addEventListener("loadedmetadata", function() {
            objectFit(this);
          });
        }
      }
    }

    return true;
  }
1070007
def get_input_media(
        media, *,
        is_photo=False, attributes=None, force_document=False,
        voice_note=False, video_note=False, supports_streaming=False
):
    
    try:
        if media.SUBCLASS_OF_ID == 0xfaf846f4:  # crc32(b'InputMedia')
            return media
        elif media.SUBCLASS_OF_ID == 0x846363e0:  # crc32(b'InputPhoto')
            return types.InputMediaPhoto(media)
        elif media.SUBCLASS_OF_ID == 0xf33fdb68:  # crc32(b'InputDocument')
            return types.InputMediaDocument(media)
    except AttributeError:
        _raise_cast_fail(media, 'InputMedia')

    if isinstance(media, types.MessageMediaPhoto):
        return types.InputMediaPhoto(
            id=get_input_photo(media.photo),
            ttl_seconds=media.ttl_seconds
        )

    if isinstance(media, (types.Photo, types.photos.Photo, types.PhotoEmpty)):
        return types.InputMediaPhoto(
            id=get_input_photo(media)
        )

    if isinstance(media, types.MessageMediaDocument):
        return types.InputMediaDocument(
            id=get_input_document(media.document),
            ttl_seconds=media.ttl_seconds
        )

    if isinstance(media, (types.Document, types.DocumentEmpty)):
        return types.InputMediaDocument(
            id=get_input_document(media)
        )

    if isinstance(media, (types.InputFile, types.InputFileBig)):
        if is_photo:
            return types.InputMediaUploadedPhoto(file=media)
        else:
            attrs, mime = get_attributes(
                media,
                attributes=attributes,
                force_document=force_document,
                voice_note=voice_note,
                video_note=video_note,
                supports_streaming=supports_streaming
            )
            return types.InputMediaUploadedDocument(
                file=media, mime_type=mime, attributes=attrs)

    if isinstance(media, types.MessageMediaGame):
        return types.InputMediaGame(id=media.game.id)

    if isinstance(media, types.MessageMediaContact):
        return types.InputMediaContact(
            phone_number=media.phone_number,
            first_name=media.first_name,
            last_name=media.last_name,
            vcard=''
        )

    if isinstance(media, types.MessageMediaGeo):
        return types.InputMediaGeoPoint(geo_point=get_input_geo(media.geo))

    if isinstance(media, types.MessageMediaVenue):
        return types.InputMediaVenue(
            geo_point=get_input_geo(media.geo),
            title=media.title,
            address=media.address,
            provider=media.provider,
            venue_id=media.venue_id,
            venue_type=''
        )

    if isinstance(media, (
            types.MessageMediaEmpty, types.MessageMediaUnsupported,
            types.ChatPhotoEmpty, types.UserProfilePhotoEmpty,
            types.ChatPhoto, types.UserProfilePhoto,
            types.FileLocationToBeDeprecated)):
        return types.InputMediaEmpty()

    if isinstance(media, types.Message):
        return get_input_media(media.media, is_photo=is_photo)

    _raise_cast_fail(media, 'InputMedia')
137641
def parse_media_type(media_type)
      m = media_type.to_s.match(/^\s*([a-zA-Z*]+)\s*\/\s*([a-zA-Z0-9*\-.+]+)\s*(?:;(.+))?$/)
      m ? [m[1].downcase, m[2].downcase, m[3] || ''] : []
    end
949408
def _get_view_media(self):
        
        try:
            css = self.Media.css
        except AttributeError:
            css = {}
        try:
            js = self.Media.js
        except AttributeError:
            js = []
        return Media(css=css, js=js)
1352411
def get_normal_image_url(self, page=1):
        
        template = self.resources.page.get('image')
        return template.replace(
            "{page}",
            str(page)
        ).replace("{size}", "normal")
917093
def media(self, form):
        
        js = ['admin/js/core.js', 'admin/js/admin/RelatedObjectLookups.js',
              'admin/js/jquery.min.js', 'admin/js/jquery.init.js']

        media = forms.Media(
            js=['%s%s' % (settings.STATIC_URL, u) for u in js],
        )

        if form:
            for name, field in form.fields.items():
                media = media + field.widget.media

        return media
1042479
def info(self, media_id):
        
        dr = self.__app.native_api_call('media', 'i/' + media_id, {}, self.__options, False, None, False, http_path="/api/meta/v1/", http_method='GET')
        return json.loads(dr.text)