# Path: module/plugins/internal/misc.py
# def fsjoin(*args):
#     """
#     Like os.path.join, but encoding aware
#     (for safe-joining see `safejoin`)
#     """
#     return encode(os.path.join(*args))
# 
# def replace_patterns(value, rules):
#     for r in rules:
#         try:
#             pattern, repl, flags = r
# 
#         except ValueError:
#             pattern, repl = r
#             flags = 0
# 
#         value = re.sub(pattern, repl, value, flags)
# 
#     return value


import binascii
import re
import Crypto.Cipher.AES
from ..captcha.SolveMedia import SolveMedia
from ..internal.Captcha import Captcha
from ..internal.Crypter import Crypter
from ..internal.misc import fsjoin, replace_patterns
    __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es"),
                   ("AndroKev", "neureither.kevin@gmail.com")]

    URL_REPLACEMENTS = [(__pattern__ + '.*', r'http://relink.to/f/\g<ID>')]

    PREFERRED_LINK_SOURCES = ["cnl2", "dlc", "web"]

    OFFLINE_TOKEN = r'<title>Tattooside'

    PASSWORD_TOKEN = r'container_password.php'
    PASSWORD_ERROR_ROKEN = r'You have entered an incorrect password'
    PASSWORD_SUBMIT_URL = r'http://relink.to/container_password.php'

    CAPTCHA_TOKEN = r'container_captcha.php'
    CIRCLE_CAPTCHA_PATTERN = r'id="captcha_id" value="(\w+?)"'
    CAPTCHA_ERROR_ROKEN = r'You have solved the captcha wrong'
    CIRCLE_CAPTCHA_IMG_URL = r'http://relink.to/core/captcha/circlecaptcha.php'
    CAPTCHA_SUBMIT_URL = r'http://relink.to/container_captcha.php'

    FILE_TITLE_PATTERN = r'<th>Title</th><td>(.*)</td></tr>'
    FILE_NOTITLE = r'No title'

    CNL2_FORM_PATTERN = r'<form id="cnl_form-(.*?)</form>'
    CNL2_FORMINPUT_PATTERN = r'<input.*?name="%s".*?value="(.*?)"'
    CNL2_JK_KEY = "jk"
    CNL2_CRYPTED_KEY = "crypted"

    DLC_LINK_PATTERN = r'<a href=".*?" class="dlc_button" target="_blank">'
    DLC_DOWNLOAD_URL = r'http://relink.to/download.php'


# Path: module/plugins/internal/misc.py
# def fsjoin(*args):
#     """
#     Like os.path.join, but encoding aware
#     (for safe-joining see `safejoin`)
#     """
#     return encode(os.path.join(*args))
# 
# def replace_patterns(value, rules):
#     for r in rules:
#         try:
#             pattern, repl, flags = r
# 
#         except ValueError:
#             pattern, repl = r
#             flags = 0
# 
#         value = re.sub(pattern, repl, value, flags)
# 
#     return value


# Path: module/plugins/crypter/RelinkUs.py
import binascii
import re
import Crypto.Cipher.AES
from ..captcha.SolveMedia import SolveMedia
from ..internal.Captcha import Captcha
from ..internal.Crypter import Crypter
from ..internal.misc import fsjoin, replace_patterns

    __authors__ = [("fragonib", "fragonib[AT]yahoo[DOT]es"),
                   ("AndroKev", "neureither.kevin@gmail.com")]

    URL_REPLACEMENTS = [(__pattern__ + '.*', r'http://relink.to/f/\g<ID>')]

    PREFERRED_LINK_SOURCES = ["cnl2", "dlc", "web"]

    OFFLINE_TOKEN = r'<title>Tattooside'

    PASSWORD_TOKEN = r'container_password.php'
    PASSWORD_ERROR_ROKEN = r'You have entered an incorrect password'
    PASSWORD_SUBMIT_URL = r'http://relink.to/container_password.php'

    CAPTCHA_TOKEN = r'container_captcha.php'
    CIRCLE_CAPTCHA_PATTERN = r'id="captcha_id" value="(\w+?)"'
    CAPTCHA_ERROR_ROKEN = r'You have solved the captcha wrong'
    CIRCLE_CAPTCHA_IMG_URL = r'http://relink.to/core/captcha/circlecaptcha.php'
    CAPTCHA_SUBMIT_URL = r'http://relink.to/container_captcha.php'

    FILE_TITLE_PATTERN = r'<th>Title</th><td>(.*)</td></tr>'
    FILE_NOTITLE = r'No title'

    CNL2_FORM_PATTERN = r'<form id="cnl_form-(.*?)</form>'
    CNL2_FORMINPUT_PATTERN = r'<input.*?name="%s".*?value="(.*?)"'
    CNL2_JK_KEY = "jk"
    CNL2_CRYPTED_KEY = "crypted"

    DLC_LINK_PATTERN = r'<a href=".*?" class="dlc_button" target="_blank">'
    DLC_DOWNLOAD_URL = r'http://relink.to/download.php'


    WEB_FORWARD_PATTERN = r'getFile\(\'(.+)\'\)'