All pastes #2110168 Raw Edit

Anonymous

public text v1 · immutable
#2110168 ·published 2012-02-06 11:49 UTC
rendered paste body
    //jDownloader - Downloadmanager
    //Copyright (C) 2010  JD-Team support@jdownloader.org
    //
    //This program is free software: you can redistribute it and/or modify
    //it under the terms of the GNU General Public License as published by
    //the Free Software Foundation, either version 3 of the License, or
    //(at your option) any later version.
    //
    //This program is distributed in the hope that it will be useful,
    //but WITHOUT ANY WARRANTY; without even the implied warranty of
    //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    //GNU General Public License for more details.
    //
    //You should have received a copy of the GNU General Public License
    //along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    package jd.plugins.hoster;
     
    import java.io.File;
    import java.io.IOException;
     
    import jd.PluginWrapper;
    import jd.nutils.encoding.Encoding;
    import jd.parser.html.Form;
    import jd.parser.html.Form.MethodType;
    import jd.plugins.DownloadLink;
    import jd.plugins.DownloadLink.AvailableStatus;
    import jd.plugins.HostPlugin;
    import jd.plugins.LinkStatus;
    import jd.plugins.PluginException;
    import jd.plugins.PluginForHost;
    import jd.utils.JDUtilities;
     
    import org.appwork.utils.formatter.SizeFormatter;
     
    @HostPlugin(revision = "$Revision$", interfaceVersion = 2, names = { "ultrafiles.com" }, urls = { "http://(www\\.)?ultrafiles\\.com/[A-Za-z0-9]+/[^<>\"\\']+" }, flags = { 0 })
    public class UltraFilesCom extends PluginForHost {
     
        public UltraFilesCom(PluginWrapper wrapper) {
            super(wrapper);
        }
     
        @Override
        public String getAGBLink() {
            return "http://ultrafiles.com/about_tos.html";
        }
     
        @Override
        public AvailableStatus requestFileInformation(DownloadLink link) throws IOException, PluginException {
            this.setBrowserExclusive();
            br.setFollowRedirects(true);
            br.getPage(link.getDownloadURL());
            if (br.containsHTML("(>Error occured</|>Such page does not exist<|<title>UltraFiles, free file hostingUltraFiles, free file hosting</title>)")) throw new PluginException(LinkStatus.ERROR_FILE_NOT_FOUND);
            String filename = br.getRegex("class=\"downloadFile\">Downloading:[\n\t\r ]+<span title=\"([^<>\"]+)\"").getMatch(0);
            if (filename == null) filename = br.getRegex("<title>([^<>\"]+)</title>").getMatch(0);
            String filesize = br.getRegex("<span style=\"color:#909090;font\\-size:12px;\">\\(\\)</span>").getMatch(0);
            if (filename == null || filesize == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
            link.setName(Encoding.htmlDecode(filename.trim()));
            link.setDownloadSize(SizeFormatter.getSize(filesize));
            return AvailableStatus.TRUE;
        }
     
        @Override
        public void handleFree(DownloadLink downloadLink) throws Exception, PluginException {
            requestFileInformation(downloadLink);
            if (br.containsHTML("ALL SLOTS FROM YOUR COUNTRY ARE TAKEN RIGHT NOW<")) throw new PluginException(LinkStatus.ERROR_HOSTER_TEMPORARILY_UNAVAILABLE, "No free slots available", 10 * 60 * 1000l);
            PluginForHost recplug = JDUtilities.getPluginForHost("DirectHTTP");
            jd.plugins.hoster.DirectHTTP.Recaptcha rc = ((DirectHTTP) recplug).getReCaptcha(br);
            Form dlForm = new Form();
            dlForm.setMethod(MethodType.POST);
            rc.setForm(dlForm);
            String id = this.br.getRegex("\\?k=([A-Za-z0-9%_\\+\\- ]+)\"").getMatch(0);
            rc.setId(id);
            for (int i = 0; i <= 5; i++) {
                rc.load();
                File cf = rc.downloadCaptcha(getLocalCaptchaFile());
                String c = getCaptchaCode(cf, downloadLink);
                rc.setCode(c);
            }
            String dllink = br.getRegex("").getMatch(0);
            if (dllink == null) dllink = br.getRegex("").getMatch(0);
            if (dllink == null) throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
            dl = jd.plugins.BrowserAdapter.openDownload(br, downloadLink, dllink, true, 0);
            if (dl.getConnection().getContentType().contains("html")) {
                br.followConnection();
                throw new PluginException(LinkStatus.ERROR_PLUGIN_DEFECT);
            }
            dl.startDownload();
        }
     
        @Override
        public void reset() {
        }
     
        @Override
        public int getMaxSimultanFreeDownloadNum() {
            return -1;
        }
     
        @Override
        public void resetDownloadlink(DownloadLink link) {
        }
     
    }