update.py

edit
# [[Emoji]] page updater code, needs Python and pywikibot https://www.mediawiki.org/wiki/Manual:Pywikibot/Installation in order to run
#
import pywikibot, json, urllib
commons = pywikibot.Site('commons', 'commons')
emojiData = json.loads(pywikibot.Page(commons, 'Data:Emoji/List.tab').text)

def emojiFileName(theme, unicode):
    unicode = unicode.replace('fe0f_20e3', '20e3') # keycaps names fix
    if theme == 'noto': return 'Noto Emoji v2.034 ' + unicode.replace('_fe0f', '').replace('_', ' ') + '.svg'
    if theme == 'twitter': return 'Twemoji13 ' + unicode.lstrip('0').replace('_', '-') + '.svg'
    if theme == 'fx': return 'Fxemoji u' + unicode.upper().replace('_', ' ') + '.svg'
    if theme == 'one': return 'Emojione ' + unicode.upper().replace('_', '-') + '.svg'
    if theme == 'one-bw': return 'Emojione BW ' + unicode.upper().replace('_', '-') + '.svg'
    if theme == 'phantom': return 'Phantom Open Emoji ' + unicode.replace('_', ' ') + '.svg'
    if theme == 'openmoji': return 'OpenMoji-color ' + unicode.upper().replace('_', '-') + '.svg'
    if theme == 'openmoji-black': return 'OpenMoji-black ' + unicode.upper().replace('_', '-') + '.svg'

#emojiData['data'] = emojiData['data'][:5]

def availableEmojisOfTheme(theme):
    print('Retrieving available Emojis of "%s"' % theme)
    return list(json.loads(urllib.request.urlopen("https://linkstranslator.toolforge.org/", urllib.parse.urlencode({
        "p": '|'.join(['File:' + emojiFileName(theme, emoji[1]) for emoji in emojiData['data']]),
        "from": "commons",
        "to": "commons"
    }).encode('utf-8')).read().decode('utf-8')).keys())

availableEmojis = {theme: availableEmojisOfTheme(theme) for theme in ['noto', 'twitter','one', 'one-bw', 'fx', 'phantom', 'openmoji', 'openmoji-black']}

def resolveEmoji(theme, unicode):
    name = "File:" + emojiFileName(theme, unicode)
    if name not in availableEmojis[theme]: return ''
    return ' [[' + name + '|48px]]'

text = """{{:Emoji/Table/Intro}}
{| class="wikitable sortable" style="text-align: center; table-layout: fixed;"
|-
! # !! %s !! %s !! %s !! %s !! %s !! %s !! %s !! %s !! %s !! %s !! %s""" % (
    'Unicode',
    'Name and keywords',
    'Emoji',
    '{{c|Noto Color Emoji|Noto Color Emoji}}',
    '{{c|Twitter Emoji|Twitter Emoji}}',
    '{{c|Emoji One|EmojiOne v2}}',
    '{{c|Emoji One BW|EmojiOne v2 BW}}',
    '{{c|Firefox OS Emoji|Firefox OS Emoji}}',
    '{{c|Phantom Open Emoji|Phantom Open Emoji}}',
    '{{c|OpenMoji Color|OpenMoji}}',
    '{{c|OpenMoji Black|OpenMoji Black}}'
)

for i, emoji in enumerate(emojiData['data']):
    text += """
|-
! %d
| %s
|style="text-align: initial"| %s
|style="font-size: 48px; line-height: 0.5;"| %s
|%s
|%s
|%s
|%s
|%s
|%s
|%s
|%s""" % (
        i + 1,
        ' <br> '.join(['<code>' + code + '</code>' for code in emoji[1].split('_')]),
        emoji[2]['en'] + ' <br><small>(' + emoji[3]['en'].replace(' |', ',') + ')</small>',
        emoji[0],
        resolveEmoji('noto', emoji[1]),
        resolveEmoji('twitter', emoji[1]),
        resolveEmoji('one', emoji[1]),
        resolveEmoji('one-bw', emoji[1]),
        resolveEmoji('fx', emoji[1]),
        resolveEmoji('phantom', emoji[1]),
        resolveEmoji('openmoji', emoji[1]),
        resolveEmoji('openmoji-black', emoji[1])
    )

page = pywikibot.Page(commons, 'Emoji/Table')
page.text = text + '\n|}'
page.save("update from [[Data:Emoji/List.tab]]")

no listed images

edit
import pymysql
import pandas as pd
import pywikibot as pwb
conn = pymysql.connect(host='commonswiki.labsdb', read_default_file="~/replica.my.cnf")
conn.cursor().execute('use commonswiki_p')
df = pd.read_sql_query("""
SELECT page_title
  FROM page
 WHERE page_namespace = 6
   AND page_title LIKE 'Noto_Emoji_v2.034_%'
   AND page_title NOT IN (
     SELECT il_to
     FROM imagelinks
     WHERE il_from = (
       SELECT page_id
         FROM page
        WHERE page_title = 'Emoji/Table'
          AND page_namespace = 0
     )
   )
""", conn)
site = pwb.Site('commons', 'commons')
page = pwb.Page(site, 'Talk:Emoji/Not_used_Noto_Emoji_v2.034')
page.text = '<gallery>\n' + '\n'.join([(b'File:' + title + b'|' + title).decode('utf8') for title in df['page_title']]) + '\n</gallery>'
page.save('Update')

androidemojis.py

edit
import fontforge, re
# https://github.com/aosp-mirror/platform_frameworks_base/blob/jb-mr2.0.0-release/data/fonts/AndroidEmoji.ttf
for g in fontforge.open('AndroidEmoji.ttf').glyphs():
    if g.codepoint == None:
        print(g.glyphname + ' has not code')
        continue
    name = 'Android Emoji ' + g.codepoint.lower().replace('u+', '') + '.svg'
    g.export(name)
    file = open(name)
    orig = file.read()
    text = re.sub('viewBox="([-\d]+) ([-\d]+) ([-\d]+) ([-\d]+)"',
                  lambda m: 'viewBox="%s %s %s %s"' % (
                      int(m.group(1)) - 30,
                      int(m.group(2)) + 200,
                      int(m.group(3)) - 30,
                      int(m.group(4)) + 200
                  ),
                  orig)
    file.close()
    file = open(name, 'w')
    file.write(text)
    file.close()

disable throttle

edit
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 24d2266..f9d65af 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -251,7 +251,7 @@ class Throttle(object):
         else:
             pywikibot.log(message)
 
-        time.sleep(seconds)
+        #time.sleep(seconds)
 
     def __call__(self, requestsize=1, write=False):
         """Block the calling program if the throttle time has not expired.

update.py

edit
# very very very unclean code and I should clean it up sometime, needs python 3
import pywikibot
import os
from tqdm import *
import hashlib
import urllib

commons = pywikibot.Site()
commons.login()
pywikibot.config.put_throttle = 0

def hash_file(file):
    return hashlib.sha512(file.read()).hexdigest()

for f in tqdm(os.listdir('/home/ebrahim/a')):
    #if '-' in f:
    #    continue

    fileName = '/home/ebrahim/a/' + f
    #title = 'Emojione1_' + f #.split('-')[0] + '.svg'
    title = f
    #print(title)
    source_hash = hash_file(open(fileName, 'rb'))
    page = pywikibot.FilePage(commons, title='File:' + title)

    if page.exists():
        continue
        #try:
        dest_hash = hash_file(urllib.request.urlopen(page.fileUrl()))
        #except:
        #    print("skipped")
        #    continue

        if source_hash == dest_hash:
            print('%s was already updated' % (title))
        else:
            commons.upload(page, source_filename=fileName, comment='update', ignore_warnings=True)

        #p = pywikibot.FilePage(commons, title='File:' + 'Emojione_' + f)
        #if p.exists() and (p.title() != page.title()):
        #    p.delete('Dupe to [[File:' + title + ']]')

    elif False and f.replace('.svg', '').upper() != f.replace('.svg', ''):
        p = pywikibot.Page(commons, title='File:' + 'Emojione_BW_' + f)
        if p.exists():
            p.move('File:' + 'Emojione_BW_' + f.upper().replace('.SVG', '.svg'), 'normalize files names', deleteAndMove=True)

    #p = pywikibot.Page(commons, title='File:' + 'Emojione_BW_' + f)
    #if p.exists() and p.isRedirectPage():
    #    p.delete('Dupe to [[File:' + title + ']]')
    #continue
    commons.upload(page, source_filename=fileName, comment="""=={{int:filedesc}}==
{{Information
|description = {{en|A colored [[:en:Emoji|Emoji]] from Android project}}
|date = 2012-07-11
|source = Project URL
|author = AuthorAuthor
}}

=={{int:license-header}}==
{{Apache|AuthorAuthor}}

[[Category:CATCATCAT]]""", ignore_warnings=True)

move.py

edit
import pywikibot
from tqdm import *
commons = pywikibot.Site('commons', 'commons')
poeList = pywikibot.Page(commons, 'User:Ebrahim/sandbox2')
_, *poe = [line.split(' -> ') for line in poeList.text.split('\n')]

for row in tqdm(poe):
    page = pywikibot.FilePage(commons, 'File:' + row[0])
    if page.isRedirectPage():
        continue
    page.move('File:Phantom Open Emoji ' + row[1] + '.svg', 'normalizing Emoji files names per [[Talk:Emoji]]')
    #break
edit
import pywikibot, json, urllib
from tqdm import *

commons = pywikibot.Site("commons", "commons")
emojiData = json.loads(pywikibot.Page(commons, 'Data:Emoji/List.tab').text)

def emojiFileName(theme, unicode):
    unicode = unicode.replace('fe0f_20e3', '20e3') # keycaps names fix
    if theme == 'noto': return 'Noto Emoji v2.034 ' + unicode.replace('_', ' ') + '.svg'
    if theme == 'twitter': return 'Twemoji13 ' + unicode.lstrip('0').replace('_', '-') + '.svg'
    if theme == 'fx': return 'Fxemoji u' + unicode.upper().replace('_', ' ') + '.svg'
    if theme == 'one': return 'Emojione ' + unicode.upper().replace('_', '-') + '.svg'
    if theme == 'one-bw': return 'Emojione BW ' + unicode.upper().replace('_', '-') + '.svg'
    if theme == 'phantom': return 'Phantom Open Emoji ' + unicode.replace('_', ' ') + '.svg'
    if theme == 'openmoji': return 'OpenMoji-color ' + unicode.upper().replace('_', '-') + '.svg'
    if theme == 'openmoji-black': return 'OpenMoji-black ' + unicode.upper().replace('_', '-') + '.svg'

def availableEmojisOfTheme(theme):
    print('Retrieving available Emojis of "%s"' % theme)
    return list(json.loads(urllib.request.urlopen("https://linkstranslator.toolforge.org/", urllib.parse.urlencode({
        "p": '|'.join(['File:' + emojiFileName(theme, emoji[1]) for emoji in emojiData['data']]),
        "from": "commons",
        "to": "commons"
    }).encode("utf-8")).read()).keys())

for title in tqdm(availableEmojisOfTheme("twitter")[:2]):
    p = pywikibot.Page(commons, title)
    p.text = (
        p.text
        .replace("|source = https://github.com/twitter/twemoji/tree/master/assets\n",
                 "|source = https://github.com/twitter/twemoji/tree/master/assets/svg" +
                     p.title(underscore=True).replace("File:Twemoji13_", "") + "\n")
    )
    p.save("use a permanent link as source")
Return to "Emoji/code" page.