API:Duplicatefiles
本頁使用了標題或全文手工轉換
Appearance
From mediawiki.org
This page is a translated version of the page API:Duplicatefiles and the translation is 82% complete.
Languages:
本页是MediaWiki Action API帮助文档的一部分。
| MediaWiki Action API |
|---|
| 基础 |
| 认证 |
| 账号和用户 |
| 页面操作 |
| 搜索 |
| 开发员工具 |
| 教程 |
| 查 · 论 · 编 |
GET request to get a list of duplicates of the given file.
MediaWiki版本:
≥ 1.14
API帮助文档
prop=duplicatefiles (df)
- This module requires read rights.
- This module can be used as a generator.
- Source: MediaWiki
- License: GPL-2.0-or-later
List all files that are duplicates of the given files based on hash values.
Specific parameters:
Other general parameters are available.
- dflimit
How many duplicate files to return.
- Type: integer or max
- The value must be between 1 and 500.
- Default: 10
- dfcontinue
When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.
- dfdir
The direction in which to list.
- One of the following values: ascending, descending
- Default: ascending
- dflocalonly
Look only for files in the local repository.
- Type: boolean (details)
Examples:
- Look for duplicates of File:Albert Einstein Head.jpg.
- api.php?action=query&titles=File:Albert_Einstein_Head.jpg&prop=duplicatefiles [open in sandbox]
- Look for duplicates of all files.
- api.php?action=query&generator=allimages&prop=duplicatefiles [open in sandbox]
示例
GET请求
列出两个重复图像。
回应
{ "batchcomplete":"", "query":{ "normalized":[ { "from":"Image:1995.jpg", "to":"File:1995.jpg" }, { "from":"Image:Welcome.gif", "to":"File:Welcome.gif" } ] ... } } } }
示例代码
Python
#!/usr/bin/python3 """ duplicate_files.py MediaWiki API Demos Demo of `Duplicatefiles` module: List duplicates of the given files. MIT License """ importrequests S = requests.Session() URL = "https://en.wikipedia.org/w/api.php" PARAMS = { "action": "query", "titles": "Image:1995.jpg|Image:Welcome.gif", "prop": "duplicatefiles", "format": "json" } R = S.get(url=URL, params=PARAMS) DATA = R.json() print(DATA)
PHP
<?php /* duplicate_files.php MediaWiki API Demos Demo of `Duplicatefiles` module: List duplicates of the given files. MIT License */ $endPoint = "https://en.wikipedia.org/w/api.php"; $params = [ "action" => "query", "titles" => "Image:1995.jpg|Image:Welcome.gif", "prop" => "duplicatefiles", "format" => "json" ]; $url = $endPoint . "?" . http_build_query( $params ); $ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); $output = curl_exec( $ch ); curl_close( $ch ); echo( $output );
JavaScript
/* duplicate_files.js MediaWiki API Demos Demo of `Duplicatefiles` module: List duplicates of the given files. MIT License */ varurl="https://en.wikipedia.org/w/api.php"; varparams={ action:"query", titles:"Image:1995.jpg|Image:Welcome.gif", prop:"duplicatefiles", format:"json" }; request.get({url:url,qs:params},function(error,res,body){ if(error){ return; } console.log(body); });
MediaWiki JS
/* duplicate_files.js MediaWiki API Demos Demo of `Duplicatefiles` module: List duplicates of the given files. MIT License */ varparams={ action:"query", titles:"Image:1995.jpg|Image:Welcome.gif", prop:"duplicatefiles", format:"json" }, api=newmw.Api(); api.get(params).done(function(data){ console.log(data); });
参数历史
- v1.20: 啟用
dfdir,dflocalonly
参阅
- API:Fileinfo - 在MediaWiki Action API的未来版本中取代这个
prop。 - API:stashimageinfo - 检索有关存储映像的信息。
- API:Images - 检索页面上嵌入的所有图像。
- API:Info - retrieves basic information about a list of pages.
- API:Imageusage - 查找使用给定图像的所有页面。
- API:Imageinfo - retrieves information about an image file or files.