Skip to content

basisvectors/mega-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

mega-checker

check if mega link is dead or not

import re
from random import randint
regex = r"https:\/\/mega\.nz\/(file|folder)\/[\s\S]*#[\s\S]*"
api = 'https://g.api.mega.co.nz'

def isUrlValid(url: str) -> bool:

    match = re.match(regex, url)
    if not match and match.group() == url:
        return False
    urltype = url.split("/")[3]
    id = url.split("/")[4].split("#")[0]
    
    if (urltype == 'folder'):
        data = { "a": "f", "c": 1, "r": 1, "ca": 1 }
    else:
        data = { "a": 'g', "p": id }
    params = {
    'id': ''.join(["{}".format(randint(0, 9)) for num in range(0, 10)]),
    'n': id
    }

    response = requests.post('https://g.api.mega.co.nz/cs', params=params, data=data)

    return response.json() == -2

About

check if mega link is valid or not

Topics

Resources

License

Stars

Watchers

Forks

Languages