#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import string
from urllib import unquote
from module.plugins.Hoster import Hoster
from module.plugins.ReCaptcha import ReCaptcha
from module.utils import chunks
from module.network.RequestFactory import getURL
from module.common.json_layer import json_loads
def getInfo(urls):
for chunk in chunks(urls, 20):
result = []
ids = dict()
for url in chunk:
id = getId(url)
if id:
ids[id] = url
else:
result.append((None, 0, 1, url))
if len(ids) > 0:
check_url = "http://api.filesonic.com/link?method=getInfo&format=json&ids=" + ",".join(ids.keys())
response = json_loads(getURL(check_url, decode=True))
for item in response["FSApi_Link"]["getInfo"]["response"]["links"]:
if item["status"] != "AVAILABLE":
result.append((ids[str(item["id"])], 0, 1, ids[str(item["id"])]))
else:
result.append((unquote(item["filename"]), item["size"], 2, ids[str(item["id"])]))
yield result
def getId(url):
match = re.search(FilesonicCom.FILE_ID_PATTERN, url)
if match:
return string.replace(match.group("id"), "/", "-")
else:
return None
class FilesonicCom(Hoster):
__name__ = "FilesonicCom"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?(sharingmatrix|filesonic)\..*?/.*?file/([a-zA-Z0-9]+(/.+)?|[a-z0-9]+/[0-9]+(/.+)?|[0-9]+(/.+)?)"
__version__ = "0.35"
__description__ = """FilesonicCom und Sharingmatrix Download Hoster"""
__author_name__ = ("jeix", "paulking")
__author_mail__ = ("jeix@hasnomail.de", "")
API_ADDRESS = "http://api.filesonic.com"
URL_DOMAIN_PATTERN = r'(?P