A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
преди 10 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <%def name="do_indent(size)">
  2. % for i in xrange(size):
  3. <div class="indent"></div>
  4. % endfor
  5. </%def>\
  6. <%def name="walk_json(obj, indent=0)">
  7. % if isinstance(obj, dict):
  8. {
  9. % for key, value in obj.iteritems():
  10. ${do_indent(indent + 1)}
  11. "${key | h}": ${walk_json(key, indent + 1)}${"," if not loop.last else ""}
  12. % endfor
  13. ${do_indent(indent)}
  14. }
  15. % elif isinstance(obj, list):
  16. [
  17. % for member in obj:
  18. ${do_indent(indent + 1)}
  19. ${walk_json(member, indent + 1)}${"," if not loop.last else ""}
  20. % endfor
  21. ${do_indent(indent)}
  22. ]
  23. % else:
  24. ${obj | h}
  25. % endif
  26. </%def>\
  27. <!DOCTYPE html>
  28. <html lang="en">
  29. <head>
  30. <meta charset="utf-8">
  31. <title>API - Earwig's Copyvio Detector</title>
  32. <link rel="stylesheet" href="${request.script_root}/static/api.min.css" type="text/css" />
  33. </head>
  34. <body>
  35. % if help:
  36. <div id="help">
  37. <h1>Copyvio Detector API</h1>
  38. <p>This is the first version of the <a href="//en.wikipedia.org/wiki/Application_programming_interface">API</a> for <a href="${request.script_root}">Earwig's Copyvio Detector</a>. It works, but some bugs might still need to be ironed out, so please <a href="https://github.com/earwig/copyvios/issues">report any</a> if you see them.</p>
  39. <h2>Requests</h2>
  40. <p>The API responds to GET requests made to <span class="code">https://tools.wmflabs.org/copyvios/api.json</span>. Parameters are described in the tables below:</p>
  41. <table class="parameters">
  42. <tr>
  43. <th colspan="4">Always</th>
  44. </tr>
  45. <tr>
  46. <th>Parameter</th>
  47. <th>Values</th>
  48. <th>Required?</th>
  49. <th>Description</th>
  50. </tr>
  51. <tr>
  52. <td>action</td>
  53. <td><span class="code">compare</span>, <span class="code">search</span>, <span class="code">sites</span></td>
  54. <td>Yes</td>
  55. <td>The API will do URL comparisons in <span class="code">compare</span> mode, run full copyvio checks in <span class="code">search</span> mode, and list all known site languages and projects in <span class="code">sites</span> mode.</td>
  56. </tr>
  57. <tr>
  58. <td>format</td>
  59. <td><span class="code">json</span>, <span class="code">jsonfm</span></td>
  60. <td>No&nbsp;(default:&nbsp;<span class="code">json</span>)</td>
  61. <td>The default output format is <a href="http://json.org/">JSON</a>. <span class="code">jsonfm</span> mode produces the same output, but renders it as a formatted HTML document for debugging.</td>
  62. </tr>
  63. <tr>
  64. <td>version</td>
  65. <td>integer</td>
  66. <td>No (default: <span class="code">1</span>)</td>
  67. <td>Currently, the API only has one version. You can skip this parameter, but it is recommended to include it for forward compatibility.</td>
  68. </tr>
  69. </table>
  70. <table class="parameters">
  71. <tr>
  72. <th colspan="4"><span class="code">compare</span> Mode</th>
  73. </tr>
  74. <tr>
  75. <th>Parameter</th>
  76. <th>Values</th>
  77. <th>Required?</th>
  78. <th>Description</th>
  79. </tr>
  80. <tr>
  81. <td>project</td>
  82. <td>string</td>
  83. <td>Yes</td>
  84. <td>The project code of the site the page lives on. Examples are <span class="code">wikipedia</span> and <span class="code">wiktionary</span>. A list of acceptable values can be retrieved using <span class="code">action=sites</span>.</td>
  85. </tr>
  86. <tr>
  87. <td>lang</td>
  88. <td>string</td>
  89. <td>Yes</td>
  90. <td>The language code of the site the page lives on. Examples are <span class="code">en</span> and <span class="code">de</span>. A list of acceptable values can be retrieved using <span class="code">action=sites</span>.</td>
  91. </tr>
  92. <tr>
  93. <td>title</td>
  94. <td>string</td>
  95. <td>Yes&nbsp;(either&nbsp;<span class="code">title</span>&nbsp;or&nbsp;<span class="code">oldid</span>)</td>
  96. <td>The title of the page or article to make a comparison against. Namespace must be included if the page isn't in the mainspace.</td>
  97. </tr>
  98. <tr>
  99. <td>oldid</td>
  100. <td>integer</td>
  101. <td>Yes (either <span class="code">title</span> or <span class="code">oldid</span>)</td>
  102. <td>The revision ID (also called oldid) of the page revision to make a comparison against. If both a title and oldid are given, the oldid will be used.</td>
  103. </tr>
  104. <tr>
  105. <td>url</td>
  106. <td>string</td>
  107. <td>Yes</td>
  108. <td>The URL of the suspected violation source that will be compared to the page.</td>
  109. </tr>
  110. </table>
  111. <table class="parameters">
  112. <tr>
  113. <th colspan="4"><span class="code">search</span> Mode</th>
  114. </tr>
  115. <tr>
  116. <th>Parameter</th>
  117. <th>Values</th>
  118. <th>Required?</th>
  119. <th>Description</th>
  120. </tr>
  121. <tr>
  122. <td>project</td>
  123. <td>string</td>
  124. <td>Yes</td>
  125. <td>The project code of the site the page lives on. Examples are <span class="code">wikipedia</span> and <span class="code">wiktionary</span>. A list of acceptable values can be retrieved using <span class="code">action=sites</span>.</td>
  126. </tr>
  127. <tr>
  128. <td>lang</td>
  129. <td>string</td>
  130. <td>Yes</td>
  131. <td>The language code of the site the page lives on. Examples are <span class="code">en</span> and <span class="code">de</span>. A list of acceptable values can be retrieved using <span class="code">action=sites</span>.</td>
  132. </tr>
  133. <tr>
  134. <td>title</td>
  135. <td>string</td>
  136. <td>Yes&nbsp;(either&nbsp;<span class="code">title</span>&nbsp;or&nbsp;<span class="code">oldid</span>)</td>
  137. <td>The title of the page or article to make a check against. Namespace must be included if the page isn't in the mainspace.</td>
  138. </tr>
  139. <tr>
  140. <td>oldid</td>
  141. <td>integer</td>
  142. <td>Yes (either <span class="code">title</span> or <span class="code">oldid</span>)</td>
  143. <td>The revision ID (also called oldid) of the page revision to make a check against. If both a title and oldid are given, the oldid will be used.</td>
  144. </tr>
  145. <tr>
  146. <td>use_engine</td>
  147. <td>boolean</td>
  148. <td>No (default: <span class="code">true</span>)</td>
  149. <td>Whether to use a search engine (<a href="//developer.yahoo.com/boss/search/">Yahoo! BOSS</a>) as a source of URLs to compare against the page.</td>
  150. </tr>
  151. <tr>
  152. <td>use_links</td>
  153. <td>boolean</td>
  154. <td>No (default: <span class="code">true</span>)</td>
  155. <td>Whether to compare the page against external links found in its wikitext.</td>
  156. </tr>
  157. <tr>
  158. <td>nocache</td>
  159. <td>boolean</td>
  160. <td>No (default: <span class="code">false</span>)</td>
  161. <td>Whether to bypass search results cached from previous checks. It is recommended that you don't pass this option unless a user specifically asks for it.</td>
  162. </tr>
  163. <tr>
  164. <td>noredirect</td>
  165. <td>boolean</td>
  166. <td>No (default: <span class="code">false</span>)</td>
  167. <td>Whether to avoid following redirects if the given page is a redirect.</td>
  168. </tr>
  169. <tr>
  170. <td>noskip</td>
  171. <td>boolean</td>
  172. <td>No (default: <span class="code">false</span>)</td>
  173. <td>If a suspected source is found during a check to have a sufficiently high confidence value, the check will end prematurely, and other pending URLs will be skipped. Passing this option will prevent this behavior, resulting in complete (but more time-consuming) checks.</td>
  174. </tr>
  175. </table>
  176. <h2>Responses</h2>
  177. <p>The JSON response object always contains a <span class="code">status</span> key, whose value is either <span class="code">ok</span> or <span class="code">error</span>. If an error has occurred, the response will look like this:</p>
  178. <pre>{
  179. "status": "error",
  180. "error": {
  181. "code": <span class="resp-dtype">string</span> <span class="resp-desc">error code</span>,
  182. "info": <span class="resp-dtype">string</span> <span class="resp-desc">human-readable description of error</span>
  183. }
  184. }</pre>
  185. <p>Valid responses for <span class="code">action=compare</span> and <span class="code">action=search</span> are formatted like this:</p>
  186. <pre>{
  187. "status": "ok",
  188. "meta": {
  189. "time": <span class="resp-dtype">float</span> <span class="resp-desc">time to generate results, in seconds</span>,
  190. "queries": <span class="resp-dtype">int</span> <span class="resp-desc">number of search engine queries made</span>,
  191. "cached": <span class="resp-dtype">boolean</span> <span class="resp-desc">whether or not these results are cached from an earlier search (always false in the case of action=compare)</span>,
  192. <span class="resp-cond">only if cached=true</span> "cache_time": <span class="resp-dtype">string</span> <span class="resp-desc">human-readable time of the original search that the results are cached from</span>,
  193. "redirected": <span class="resp-dtype">boolean</span> <span class="resp-desc">whether or not a redirect was followed</span>
  194. },
  195. "page": {
  196. "title": <span class="resp-dtype">string</span> <span class="resp-desc">the normalized title of the page checked</span>,
  197. "url": <span class="resp-dtype">string</span> <span class="resp-desc">the full URL of the page checked</span>
  198. },
  199. <span class="resp-cond">only if redirected=true</span> "original_page": {
  200. "title": <span class="resp-dtype">string</span> <span class="resp-desc">the normalized title of the original page whose redirect was followed</span>,
  201. "url": <span class="resp-dtype">string</span> <span class="resp-desc">the full URL of the original page whose redirect was followed</span>
  202. },
  203. "best": {
  204. "url": <span class="resp-dtype">string</span> <span class="resp-desc">the URL of the best match found, or null if no matches were found</span>,
  205. "confidence": <span class="resp-dtype">float</span> <span class="resp-desc">the confidence of a violation in the best match, or 0.0 if no matches were found</span>,
  206. "violation": <span class="resp-dtype">string</span> <span class="resp-desc">one of "suspected", "possible", or "none"</span>
  207. },
  208. "sources": [
  209. {
  210. "url": <span class="resp-dtype">string</span> <span class="resp-desc">the URL of the source</span>,
  211. "confidence": <span class="resp-dtype">float</span> <span class="resp-desc">the confidence of a violation in the source</span>,
  212. "violation": <span class="resp-dtype">string</span> <span class="resp-desc">one of "suspected", "possible", or "none"</span>,
  213. "skipped": <span class="resp-dtype">boolean</span> <span class="resp-desc">whether or not the source was skipped due to the check finishing early (see note about noskip above)</span>
  214. },
  215. ...
  216. ]
  217. }</pre>
  218. <p>In the case of <span class="code">action=search</span>, <span class="code">sources</span> will contain one entry for each source checked (or skipped if the check ends early), sorted in order of confidence, with skipped sources at the bottom.</p>
  219. <p>In the case of <span class="code">action=compare</span>, <span class="code">best</span> will always contain information about the URL that was given, so <span class="code">response["best"]["url"]</span> will never be <span class="code">null</span>. Also, <span class="code">sources</span> will always contain one entry, with the same data as <span class="code">best</span>, since only one source is checked in comparison mode.</p>
  220. <p>Valid responses for <span class="code">action=sites</span> are formatted like this:</p>
  221. <pre>{
  222. "status": "ok",
  223. "langs": [
  224. [
  225. <span class="resp-dtype">string</span> <span class="resp-desc">language code</span>,
  226. <span class="resp-dtype">string</span> <span class="resp-desc">human-readable language name</span>
  227. ],
  228. ...
  229. ],
  230. "projects": [
  231. [
  232. <span class="resp-dtype">string</span> <span class="resp-desc">project code</span>,
  233. <span class="resp-dtype">string</span> <span class="resp-desc">human-readable project name</span>
  234. ],
  235. ...
  236. ]
  237. }</pre>
  238. <h2>Caveats</h2>
  239. <ul>
  240. <li>There is currently no way to get the contents of the article or suspected source, nor can you get the data behind the visual comparison available from the main tool. This may be changed in a future version if there is sufficient demand for it.</li>
  241. <li>Requests are typically not rate-limited, but the tool uses the same workers to handle all requests, so making simultaneous API calls is only going to slow you down. In general, you are fine making an unlimited number of requests, as long as they are not concurrent and you wait a few seconds between them.</li>
  242. </ul>
  243. <h2>Example</h2>
  244. <p><a class="no-color" href="https://tools.wmflabs.org/copyvios/api.json?version=1&amp;action=search&amp;project=wikipedia&amp;lang=en&amp;title=User:The_Earwig/Sandbox/CopyvioExample"><span class="code">https://tools.wmflabs.org/copyvios/api.json?<span class="param-key">version</span>=<span class="param-val">1</span>&amp;<span class="param-key">action</span>=<span class="param-val">search</span>&amp;<span class="param-key">project</span>=<span class="param-val">wikipedia</span>&amp;<span class="param-key">lang</span>=<span class="param-val">en</span>&amp;<span class="param-key">title</span>=<span class="param-val">User:The_Earwig/Sandbox/CopyvioExample</span></span></a></p>
  245. <pre>{
  246. "status": "ok",
  247. "meta": {
  248. "time": 2.2474379539489746,
  249. "queries": 1,
  250. "cached": false,
  251. "redirected": false
  252. },
  253. "page": {
  254. "title": "User:The Earwig/Sandbox/CopyvioExample",
  255. "url": "https://en.wikipedia.org/wiki/User:The_Earwig/Sandbox/CopyvioExample"
  256. },
  257. "best": {
  258. "url": "http://www.whitehouse.gov/administration/president-obama/",
  259. "confidence": 0.9886608511242603,
  260. "violation": "suspected"
  261. }
  262. "sources": [
  263. {
  264. "url": "http://www.whitehouse.gov/administration/president-obama/",
  265. "confidence": 0.9886608511242603,
  266. "violation": "suspected",
  267. "skipped": false
  268. },
  269. {
  270. "url": "http://maige2009.blogspot.com/2013/07/barack-h-obama-is-44th-president-of.html",
  271. "confidence": 0.9864798816568047,
  272. "violation": "suspected",
  273. "skipped": false
  274. },
  275. {
  276. "url": "http://jeuxdemonstre-apkdownload.rhcloud.com/luo-people-of-kenya-and-tanzania---wikipedia--the-free",
  277. "confidence": 0.0,
  278. "violation": "none",
  279. "skipped": false
  280. },
  281. {
  282. "url": "http://www.whitehouse.gov/about/presidents/barackobama",
  283. "confidence": 0.0,
  284. "violation": "none",
  285. "skipped": true
  286. },
  287. {
  288. "url": "http://jeuxdemonstre-apkdownload.rhcloud.com/president-barack-obama---the-white-house",
  289. "confidence": 0.0,
  290. "violation": "none",
  291. "skipped": true
  292. }
  293. ]
  294. }
  295. </pre>
  296. </div>
  297. % endif
  298. % if result:
  299. <div id="result">
  300. <p>You are using <span class="code">jsonfm</span> output mode, which renders JSON data as a formatted HTML document. This is intended for testing and debugging only.</p>
  301. <div class="json">
  302. ${walk_json(result)}
  303. </div>
  304. </div>
  305. % endif
  306. </body>
  307. </html>