2014-12-08 3 views
3

Wikipedia 기사에있는 비디오 또는 오디오 파일 수를 추출하려고하는데 API를 검색했지만 그 중 하나를 찾지 못했습니다.위키 피 디아 문서의 비디오 또는 오디오 파일 수를 추출하십시오.

API를 사용하여 특정 페이지의 이미지를 추출 할 때 확장명이 .ogg 인 오디오 파일이 이미지 목록에 나타납니다.

http://ar.wikipedia.org/w/api.php?format=xml&action=parse&page=%D8%AD%D9%88%D8%AB%D9%8A%D9%88%D9%86&prop=images&redirects=

나는이 사건이 일반화 될 수 있는지 알고, 내가 비디오 및 오디오 파일을 계산하는 데 사용할 수 있는지 여부하지

? 다른 사람이 이것을 할 수있는 방법이 있습니까?

답변

1

기본적으로 모든 파일 형식은 API에 의해 동일하게 취급되지만 각 파일의 mediatype을 가져 와서 비디오 및 오디오 파일을 필터링 할 수 있습니다.

파일의 mediatype을 얻으려면 각 파일에 대해 prop=imageinfo (이 will be changed을 더 정확하게 prop=fileinfo으로 사용)을 사용하십시오. prop=images가 발전기로 사용할 수 있습니다, 당신은 this처럼, 하나의 API 호출로, 파일의 목록과 자신의 MediaType를 얻을 수 있습니다 : 여기 images

https://ar.wikipedia.org/w/api.php?action=query&generator=images&titles=%D8%AD%D9%88%D8%AB%D9%8A%D9%88%D9%86&redirects=&prop=imageinfo&iiprop=mediatype&continue=&format=xml 

을 발전기로 사용, 목록을 반환 파일의 목록에있는 파일 목록은 imageinfo 호출에 공급됩니다.

"2014232": { 
    "pageid": 2014232, 
    "ns": 6, 
    "title": "\u0645\u0644\u0641:06-Salame-Al Aadm 001.ogg", 
    "imagerepository": "local", 
    "imageinfo": [ 
    { 
     "mediatype": "AUDIO" 
    } 
    ] 
} 

mediatype합니다 (manual에서 복사 및 붙여 넣기) 다음 중 하나 일 수 있습니다 :

UNKNOWN  // unknown format 
BITMAP  // some bitmap image or image source (like psd, etc). Can't scale up. 
DRAWING  // some vector drawing (SVG, WMF, PS, ...) or image source (oo-draw, etc). Can scale up. 
AUDIO  // simple audio file (ogg, mp3, wav, midi, whatever) 
VIDEO  // simple video file (ogg, mpg, etc; no not include formats here that may contain executable sections or scripts!) 
MULTIMEDIA // Scriptable Multimedia (flash, advanced video container formats, etc) 
OFFICE  // Office Documents, Spreadsheets (office formats possibly containing apples, scripts, etc) 
TEXT  // Plain text (possibly containing program code or scripts) 
EXECUTABLE // binary executable 
ARCHIVE  // archive file (zip, tar, etc) 

기본 각 파일에 대해

, 당신은 이런 식으로 뭔가를 얻을 것이다 mimetype < => mediatype의 매핑은 here이 가능합니다. 그러나 개별 wiki에서이를 오버라이드 할 수는 있습니다.