Wikipedia:Database reports/Duplicate files/Configuration

import settings
##Config
report_title=settings.rootpage+'Duplicate files'
report_template = u'''
List of files that are exact, bit for bit duplicates of another file. The report is limited to the first 200 duplicate files that it finds, and excludes fully protected files;
data as of <onlyinclude>~~~~~</onlyinclude>.




{| class="wikitable sortable plainlinks"
|-
! First File
! Number of uses
! Second File
! Number of uses
|-
%s
|}
<small>(Took %.2f seconds to generate)</small>
'''
###
from wikipedia import Page,getSite
from time import time
site=getSite()
del getSite
from MySQLdb import connect
db = connect(host=settings.host, db=settings.dbname, read_default_file='~/.my.cnf')
t=time()
cursor=db.cursor()
cursor.execute("""SELECT CONCAT(ns_name,concat(':',replace(MAIN.img_name,'_',' '))) AS first,(Select count(*) from imagelinks as MAINCOUNT WHERE MAINCOUNT.il_to=MAIN.img_name) as firstcount, CONCAT(ns_name,concat(':',replace(LAME.img_name,'_',' ')))  as second,
	(Select count(*) from imagelinks as LAMECOUNT WHERE LAMECOUNT.il_to=LAME.img_name) as secondcount
	FROM image as MAIN
	JOIN toolserver.namespace on dbname=%s and ns_id=6
	JOIN image as LAME on LAME.img_name!=MAIN.img_name and LAME.img_sha1=MAIN.img_sha1 and LAME.img_timestamp<MAIN.img_timestamp
	JOIN page on page_namespace=6 and page_title in (MAIN.img_name,LAME.img_name)
	LEFT JOIN page_restrictions on pr_page=page_id and pr_type='edit' and pr_level='sysop'
	where isnull(pr_page) LIMIT 200;"""
	,(settings.dbname,))




t=time()-t
row=''
for firstfile,firstcount,secondfile,secondcount in cursor.fetchall():
	row+="""\n|[[:%s]]
	|[{{fullurl:Special:WhatLinksHere/%s|hidetrans=1&hidelinks=1&hideredirs=1}} %d]
	|[[:%s]]
	|[{{fullurl:Special:WhatLinksHere/%s|hidetrans=1&hidelinks=1&hideredirs=1}} %d]
	|-"""%(unicode(firstfile,'utf-8'), unicode(firstfile,'utf-8'), firstcount, unicode(secondfile,'utf-8'),unicode(secondfile,'utf-8'), secondcount)




report_template=report_template%(row,t)
report_page=Page(site,report_title)
report_page.put(report_template,comment='Updating Page...')

Crontab

40 7 * * 6 python /home/tim1357/pynew/pywikipedia/DuplicateFiles.py >/dev/null

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.