User:Thegeneralbot/unusedfiles

From The Urban Dead Wiki
Jump to navigationJump to search

Below is a description of the methodology (I.e. Step takes) of the unused images tagging script.

  1. Parse into memory a list of the first 60 pages in Special:Unusedfiles
  2. Load each page and check
    1. Whether the {{Orphanedimage}} template is in the page - if it is then skip and load the next page.
    2. Whether the last time an image was uploaded was less than a week ago - if it is then skip and load the next page.
  3. If neither of the above two cases are true then get the text of the page
  4. Scan the text for the presence of Category:Unused Images
    1. If the category is presemt then replace it with the {{Orphanedimage}} template and save the page
    2. If the category tag is not in the page then append the {{Orphanedimage}} template and save the page.
  5. If there were more than 60 pages in Special:Unusedfiles then load the next 60 pages and repeat the process - continue until there are no more pages in the list (rarely needed).
  6. Fetch list of pages in Category:Unused Images and parse into memory.
  7. Fetch list of pages in Special:Unusedfiles and parse into memory
  8. For each page in Category:Unused Images, check if it's also in Special:Unusedfiles.
    • If a page is in both then skip and continue to the next page
    • Otherwise:
      1. Get the text of the page.
      2. Remove any instances of {{Orphanedimage}} in the page text.
      3. Remove any instances of the Category:Unused Images
  9. If there were more than 60 pages in Category:Unused Images then load the next 60 pages and repeat the process - continue until there are no more pages in the list (rarely needed).