API:Dateiduplikate

This page is a translated version of the page API:Duplicatefiles and the translation is 100% complete.

GET-Abfrage um eine Liste von Duplikaten der angegebenen Datei zu erhalten.

MediaWiki Version:
1.14

API-Dokumentation

prop=duplicatefiles (df)

(main | query | duplicatefiles)
  • 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)


Beispiel

GET-Anfrage

Duplikate von zwei Bildern auflisten.

Antwort

{
    "batchcomplete": "",
    "query": {
        "normalized": [
            {
                "from": "Image:1995.jpg",
                "to": "File:1995.jpg"
            },
            {
                "from": "Image:Welcome.gif",
                "to": "File:Welcome.gif"
            }
        ]
        ...
            }
        }
    }
}

Beispielcode

Python

#!/usr/bin/python3

"""
    duplicate_files.py

    MediaWiki API Demos
    Demo of `Duplicatefiles` module: List duplicates of the given files.

    MIT License
"""

import requests

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
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    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
*/

var params = {
    action: "query",
    titles: "Image:1995.jpg|Image:Welcome.gif",
    prop: "duplicatefiles",
    format: "json"
},
api = new mw.Api();

api.get( params ).done( function ( data ) {
console.log( data );
} );

Parametergeschichte

  • v1.20: Eingeführt dfdir, dflocalonly

Siehe auch

  • API:Fileinfo - soll diese prop in zukünftigen Versionen der MediaWiki Action API ersetzen.
  • API:Stashbildinfo - ruft Informationen über Stash-Bilder ab.
  • API:Bilder - ruft alle in eine Seite eingebundenen Bilder ab.
  • API:Info - ruft Informationen über eine Liste von Seiten ab.
  • API:Bildnutzung - findet alle Seiten, die das angegebene Bild oder die angegebenen Bilder nutzen.
  • API:Bildinfo - ruft Informationen über eine Bild-Datei oder mehrere Dateien ab.