Program to Fill Missing numbers

[Forwarded from மனோஜ் ☺️]
Fill Missing numbers

IP
1.1
1.3
2.1
2.3.1
2.3.2
2.3.4

OP
1.1
1.2
1.3
2.1
2.2
2.3.1
2.3.2
2.3.3
2.3.4

Dual boot - Mac and windows

Dharun_MK, [23.07.19 13:11]
Goto https://www.hackintoshzone.com/  and download a distro like Mac os High Sierra.

Insert a pendrive Install transmac on pc and format using right click format for Mac and right click restore image and select the downloaded image file and click ok ok

Dharun_MK, [23.07.19 13:12]
Then change boot mode to uefi in bios

Dharun_MK, [23.07.19 13:12]
Hard-disk to GPT partition

Dharun_MK, [23.07.19 13:12]
And boot from pendrive

Dharun_MK, [23.07.19 13:13]
And call me I tell or see any video of install mac os  after the boot from pendrive

Auto select a list using ADB

from adb.client import Client as AdbClient
client = AdbClient(host="127.0.0.1", port=5037)
device = client.devices()[0]
from smart import *
for i in range(1,56):
 device.shell("input tap 200 500")
 device.shell("input swipe 300 300 300 190")
 # sleep(.1)
done()

Restore all lost contacts from Telegram

from telethon.sync import TelegramClient
from telethon import functions, types
with open('contacts.csv') as csv:
    column = ["SNo", "Phone","First Name ", " Last Name",]
    print(*column, sep=',',file=csv)
    with TelegramClient(name, api_id, api_hash) as client:
        with client.takeout(contacts=True) as takeout:
            result = takeout(functions.contacts.GetSavedRequest())
            for k,x in enumerate(result):
                print(k,x.phone,x.first_name,x.last_name,sep=',',file=csv)
                

Close Windows Apps Using Python

import  win32com.client
def q(fn,ftype='Excel'):
 xl = win32com.client.Dispatch(f"{ftype}.Application")
 for i in xl.Documents:
  print(i)
  if str(i)==fn:
   print(i.Close())

Subtitle Rename


from shutil import move
p=r'C:\Users\Smart\Downloads\Compressed\s'

import re
import os.path as op,os
d={}
os.chdir(p)
from glob import *
pattern=r'S\d\dE\d\d'
for i in glob('*.mkv'):
 print(i)
 k=(re.search(pattern,i,re.I)[0])
 d[k],_=op.splitext(i)

# from smart import *
# oe(p)
ext='.srt'
for i,j in enumerate(os.listdir(p)):
 if( j.endswith('.srt')):
  z=re.search(pattern,j,re.I)[0]
  if (v:=d.get(z)):
   move(j,v+ext)
  else:
   print(z)

Structurise - An OCR API

import requests



headers = {

    'Origin': 'http://www.structurise.com',

    'Accept-Encoding': 'gzip, deflate',

    'Accept-Language': 'en-US,en;q=0.9,ta;q=0.8',

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',

    'Content-type': 'application/x-www-form-urlencoded',

    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',

    'Referer': 'http://www.structurise.com/screenshot-ocr/',

    'Connection': 'keep-alive',

    'Upgrade-Insecure-Requests': '1',

}

import base64

with open(r"C:\Users\Smart\Desktop\a.jpg", "rb") as image_file:

    encoded_string = base64.b64encode(image_file.read()).decode()



img=f'data:image/png;base64,{encoded_string}'

data = {

  'lang': 'English',

  'outf': 'HTML',

  'inptype': 'PN',

  'fname': 'clipboard.png',

  'image': img

}

response = requests.post('http://www.structurise.com/wp-content/plugins/wp-struweb/struweb.php', headers=headers, data=data)



import requests



headers = {

    'Connection': 'keep-alive',

    'Upgrade-Insecure-Requests': '1',

    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',

    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',

    'Referer': 'http://www.structurise.com/screenshot-ocr/',

    'Accept-Encoding': 'gzip, deflate',

    'Accept-Language': 'en-US,en;q=0.9,ta;q=0.8',

}

params = (

    ('res', response.text.strip()),

)

import re

response = requests.get('http://www.structurise.com/wp-content/plugins/wp-struweb/struweb.php', headers=headers, params=params)



def uprint(x):

  try:

    pass

    if x:

      print(x.encode('cp65001',errors='backslashreplace').decode('cp1252'))

  except Exception as e:

    return f'{x}\n{e}'

def prin(*a):print(ascii(*a))    



uprint(re.search('<span.*?>(.*)</span>',response.text)[1].replace(' ',' '))

Export Telegram Contacts

api_id = 210829
api_hash = '..'
sn='SmartManoj2'
# api_hash from http://my.telegram.org, under API Development.


from telethon import TelegramClient, events, sync

from telethon.tl.functions.contacts import GetContactsRequest

from telethon import events

from telethon import functions, types










client = TelegramClient(sn, api_id, api_hash)

client.start()

result = client(functions.contacts.GetContactsRequest(

        hash=0

    ))



for i in result.users:

 i=i.to_dict()

 print(i['phone'],i['first_name'],i.get('last_name',''),'@'+(i.get('username') or '-'),sep=',')