Skip to content

Instantly share code, notes, and snippets.

@ChlodAlejandro
Last active September 19, 2022 15:45
Show Gist options
  • Save ChlodAlejandro/33d2e98be1f69b90d9bbd43e22e694d3 to your computer and use it in GitHub Desktop.
Save ChlodAlejandro/33d2e98be1f69b90d9bbd43e22e694d3 to your computer and use it in GitHub Desktop.
Counts the number of instances of {{CPC}} transclusions in the Wikipedia:Copyright problems pagespace.
// !!!
// This version is !! UNMAINTAINED !!
// See https://github.com/ChlodAlejandro/deputy/tree/main/scripts/cpcrc.js for an updated version.
// !!!
/**
* Counts the number of instances of {{CPC}} transclusions in the Wikipedia:Copyright problems pagespace.
* ================================================================================================
* Copyright © 2022 Chlod Aidan Alejandro
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the “Software”), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const axios = require("axios");
(async () => {
const queries = {
"Backwardscopy. Tag placed at talk page.": "backwards",
"Backwardscopy. Attributes Wikipedia.": "backwardsattributed",
"Blanked and relisted under today.": "blanked",
"Article cleaned by investigator or others. No remaining infringement.": "cleaned",
"Copyright concerns remain. Article deleted, left {{Cup}} notice.": "deletedcup",
"Article deleted due to copyright concerns.": "deletedcv",
"Article deleted for a reason other than copyright concerns.": "deletedother",
"Deferred to old issues.": "deferred",
"Article cleaned, revision deletion requested.": "histpurge",
"Rewrite moved into place.": "move",
"No copyright concern. Material is PD, license compatible, or ineligible for copyright protection.": "no",
"VRT pending but not yet verified, relisting under today's entry.": "OTRS",
"Revision deletion completed. Copyright problem removed from history.": "purged",
"Permission plausible Article relisted under today.": "relist",
"Article redirected to a non-infringing target.": "redirect",
"Issue resolved.": "resolved",
"VRT Ticket received, article now licensed and compatible with CC BY-SA 3.0.": "ticket",
"User was not notified, relisting under today's entry.": "user",
"No source found; copy-paste tag removed and cv-unsure tag placed at article talk.": "unsure",
"Permission unverified as of this tagging; article will need to be deleted if that does not change.": "unverified",
"Viable rewrite proposed; rewrite on temp page can be merged into the article.": "viable",
"No vio found, claim cannot be validated. Tag removed from article.": "where",
"Article cleaned, still needs a history purge to remove original copyvio": "histpurge",
"Viable rewrite proposed; rewrite on temp page can be used to replace problematic article": "viable",
"Rewrite requires merge; viable rewrite at temp space requires history merge into article.": "move",
"No copyright concern. Material PD or appropriately licensed for use": "no"
};
const counts = {};
for (const [query, key] of Object.entries(queries)) {
const req = await axios.post("https://en.wikipedia.org/w/api.php", new URLSearchParams({
"action": "query",
"format": "json",
"formatversion": "2",
"list": "search",
"srsearch": `intitle:\"Copyright problems\" \"${query}\"`,
"srnamespace": "4",
"srwhat": "text",
"srinfo": "totalhits",
"srprop": ""
}), { responseType: "json" });
console.log(query + ": " + req.data.query.searchinfo.totalhits);
counts[key] = (counts[key] || 0) + req.data.query.searchinfo.totalhits;
}
console.log("\nSORTING...\n");
const f = Object.entries(counts).sort((a,b)=>b[1] - a[1]);
for ( const [ key, hits ] of f ) {
console.log("'" + key + "',");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment