Program: 20889
Project: 20889
Buggy source:
public ArrayList<DownloadLink> decryptIt(CryptedLink param,ProgressController progress) throws Exception {
  possibleconverts=new HashMap<ConversionMode,ArrayList<Info>>();
  ArrayList<DownloadLink> decryptedLinks=new ArrayList<DownloadLink>();
  String parameter=param.toString().replace("String_Node_Str","String_Node_Str");
  br.setFollowRedirects(true);
  br.setCookiesExclusive(true);
  br.clearCookies("String_Node_Str");
  if (parameter.contains("String_Node_Str")) {
    parameter=parameter.replace("String_Node_Str","String_Node_Str");
  }
  if (parameter.contains("String_Node_Str")) {
    br.getPage(parameter);
    addVideosCurrentPage(decryptedLinks);
    if (!parameter.contains("String_Node_Str")) {
      String[] pages=br.getRegex("String_Node_Str").getColumn(1);
      for (int i=0; i < pages.length - 1; i++) {
        br.getPage(pages[i]);
        addVideosCurrentPage(decryptedLinks);
      }
    }
  }
 else {
    boolean prem=false;
    ArrayList<Account> accounts=AccountController.getInstance().getAllAccounts("String_Node_Str");
    if (accounts != null && accounts.size() != 0)     prem=login(accounts.get(0));
    try {
      if (StreamingShareLink.matcher(parameter).matches()) {
        String[] info=new Regex(parameter,StreamingShareLink).getMatches()[0];
        for (        String debug : info) {
          logger.info(debug);
        }
        DownloadLink thislink=createDownloadlink(info[1]);
        thislink.setBrowserUrl(info[2]);
        thislink.setFinalFileName(info[0]);
        thislink.setSourcePluginComment("String_Node_Str" + (ConversionMode.valueOf(info[3])).getText());
        thislink.setProperty("String_Node_Str",info[3]);
        decryptedLinks.add(thislink);
        return decryptedLinks;
      }
      boolean oldLayout=false;
      HashMap<Integer,String> linksFound=getLinks(parameter,prem,this.br);
      if (linksFound != null)       oldLayout=true;
      if (linksFound == null)       linksFound=getLinksNew(parameter,prem,this.br);
      if ((linksFound == null || linksFound.size() == 0) && br.containsHTML("String_Node_Str"))       throw new DecrypterException(DecrypterException.ACCOUNT);
      if (linksFound == null || linksFound.size() == 0)       throw new DecrypterException("String_Node_Str");
      String name=Encoding.htmlDecode(br.getRegex(YT_FILENAME).getMatch(0).trim());
      HashMap<Integer,String> links=new HashMap<Integer,String>();
      if (ConvertDialog.getKeeped().contains(ConversionMode.VIDEO3GP) && linksFound.keySet().contains(13)) {
        links.put(13,linksFound.get(13));
      }
 else       if (ConvertDialog.getKeeped().contains(ConversionMode.VIDEOMP4) && (linksFound.keySet().contains(18) || linksFound.keySet().contains(22) || linksFound.keySet().contains(34)|| linksFound.keySet().contains(35)|| linksFound.keySet().contains(37))) {
        Integer mp4[]=new Integer[]{18,22,34,35,37};
        for (        Integer f : mp4) {
          if (linksFound.containsKey(f)) {
            links.put(f,linksFound.get(f));
          }
        }
      }
 else {
        links=linksFound;
      }
      for (      Integer format : links.keySet()) {
        String link=links.get(format);
        String dlLink;
        if (format == 0) {
          dlLink=link;
        }
 else {
          dlLink=link + (oldLayout == true ? "String_Node_Str" + format : "String_Node_Str");
        }
switch (format) {
case 18:
          if (br.openGetConnection(dlLink).getResponseCode() == 200) {
            addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
            br.getHttpConnection().disconnect();
          }
        break;
case 22:
      if (br.openGetConnection(dlLink).getResponseCode() == 200) {
        addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
        br.getHttpConnection().disconnect();
      }
    break;
case 34:
  if (br.openGetConnection(dlLink).getResponseCode() == 200) {
    addtopos(ConversionMode.VIDEOFLV,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
    br.getHttpConnection().disconnect();
  }
break;
case 35:
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
break;
case 37:
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
if (ConvertDialog.getKeeped().contains(ConversionMode.VIDEOMP4)) break;
break;
case 13:
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEO3GP,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
break;
default :
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEOFLV,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
addtopos(ConversionMode.AUDIOMP3,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
addtopos(ConversionMode.AUDIOMP3_AND_VIDEOFLV,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
}
}
ConversionMode convertTo=Plugin.showDisplayDialog(new ArrayList<ConversionMode>(possibleconverts.keySet()),name,param);
for (Info info : possibleconverts.get(convertTo)) {
DownloadLink thislink=createDownloadlink("String_Node_Str" + info.link);
thislink.setBrowserUrl(parameter);
thislink.setFinalFileName(name + info.desc + "String_Node_Str");
thislink.setSourcePluginComment("String_Node_Str" + convertTo.getText());
thislink.setProperty("String_Node_Str",Long.valueOf(info.size));
thislink.setProperty("String_Node_Str",name + info.desc + "String_Node_Str");
thislink.setProperty("String_Node_Str",convertTo.name());
thislink.setProperty("String_Node_Str",parameter);
thislink.setProperty("String_Node_Str",true);
thislink.setProperty("String_Node_Str",info.fmt);
decryptedLinks.add(thislink);
}
}
 catch (IOException e) {
br.getHttpConnection().disconnect();
logger.log(java.util.logging.Level.SEVERE,"String_Node_Str",e);
return null;
}
}
return decryptedLinks;
}

Fixed version (ground truth):
public ArrayList<DownloadLink> decryptIt(CryptedLink param,ProgressController progress) throws Exception {
  possibleconverts=new HashMap<ConversionMode,ArrayList<Info>>();
  ArrayList<DownloadLink> decryptedLinks=new ArrayList<DownloadLink>();
  String parameter=param.toString().replace("String_Node_Str","String_Node_Str");
  br.setFollowRedirects(true);
  br.setCookiesExclusive(true);
  br.clearCookies("String_Node_Str");
  if (parameter.contains("String_Node_Str")) {
    parameter=parameter.replace("String_Node_Str","String_Node_Str");
  }
  if (parameter.contains("String_Node_Str")) {
    br.getPage(parameter);
    addVideosCurrentPage(decryptedLinks);
    if (!parameter.contains("String_Node_Str")) {
      String[] pages=br.getRegex("String_Node_Str").getColumn(1);
      for (int i=0; i < pages.length - 1; i++) {
        br.getPage(pages[i]);
        addVideosCurrentPage(decryptedLinks);
      }
    }
  }
 else {
    boolean prem=false;
    ArrayList<Account> accounts=AccountController.getInstance().getAllAccounts("String_Node_Str");
    if (accounts != null && accounts.size() != 0)     prem=login(accounts.get(0));
    try {
      if (StreamingShareLink.matcher(parameter).matches()) {
        String[] info=new Regex(parameter,StreamingShareLink).getMatches()[0];
        for (        String debug : info) {
          logger.info(debug);
        }
        DownloadLink thislink=createDownloadlink(info[1]);
        thislink.setBrowserUrl(info[2]);
        thislink.setFinalFileName(info[0]);
        thislink.setSourcePluginComment("String_Node_Str" + (ConversionMode.valueOf(info[3])).getText());
        thislink.setProperty("String_Node_Str",info[3]);
        decryptedLinks.add(thislink);
        return decryptedLinks;
      }
      boolean oldLayout=false;
      HashMap<Integer,String> linksFound=getLinks(parameter,prem,this.br);
      if (linksFound != null)       oldLayout=true;
      if (linksFound == null)       linksFound=getLinksNew(parameter,prem,this.br);
      if ((linksFound == null || linksFound.size() == 0) && br.containsHTML("String_Node_Str"))       throw new DecrypterException(DecrypterException.ACCOUNT);
      if (linksFound == null || linksFound.size() == 0)       throw new DecrypterException("String_Node_Str");
      String name=Encoding.htmlDecode(br.getRegex(YT_FILENAME).getMatch(0).trim());
      HashMap<Integer,String> links=new HashMap<Integer,String>();
      if (ConvertDialog.getKeeped().contains(ConversionMode.VIDEO3GP) && linksFound.keySet().contains(13)) {
        links.put(13,linksFound.get(13));
      }
 else       if (ConvertDialog.getKeeped().contains(ConversionMode.VIDEOMP4) && (linksFound.keySet().contains(18) || linksFound.keySet().contains(22) || linksFound.keySet().contains(34)|| linksFound.keySet().contains(35)|| linksFound.keySet().contains(37))) {
        Integer mp4[]=new Integer[]{18,22,34,35,37};
        for (        Integer f : mp4) {
          if (linksFound.containsKey(f)) {
            links.put(f,linksFound.get(f));
          }
        }
      }
 else {
        links=linksFound;
      }
      for (      Integer format : links.keySet()) {
        String link=links.get(format);
        String dlLink;
        if (format == 0) {
          dlLink=link;
        }
 else {
          dlLink=link + (oldLayout == true ? "String_Node_Str" + format : "String_Node_Str");
        }
switch (format) {
case 18:
          if (br.openGetConnection(dlLink).getResponseCode() == 200) {
            addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
            br.getHttpConnection().disconnect();
          }
        break;
case 22:
      if (br.openGetConnection(dlLink).getResponseCode() == 200) {
        addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
        br.getHttpConnection().disconnect();
      }
    break;
case 34:
  if (br.openGetConnection(dlLink).getResponseCode() == 200) {
    addtopos(ConversionMode.VIDEOFLV,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
    br.getHttpConnection().disconnect();
  }
break;
case 35:
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
break;
case 37:
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEOMP4,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
if (ConvertDialog.getKeeped().contains(ConversionMode.VIDEOMP4)) break;
break;
case 13:
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEO3GP,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
break;
default :
if (br.openGetConnection(dlLink).getResponseCode() == 200) {
addtopos(ConversionMode.VIDEOFLV,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
addtopos(ConversionMode.AUDIOMP3,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
addtopos(ConversionMode.AUDIOMP3_AND_VIDEOFLV,dlLink,br.getHttpConnection().getLongContentLength(),"String_Node_Str",format);
br.getHttpConnection().disconnect();
}
}
}
ConversionMode convertTo=Plugin.showDisplayDialog(new ArrayList<ConversionMode>(possibleconverts.keySet()),name,param);
for (Info info : possibleconverts.get(convertTo)) {
DownloadLink thislink=createDownloadlink(info.link.replaceFirst("String_Node_Str","String_Node_Str"));
thislink.setBrowserUrl(parameter);
thislink.setFinalFileName(name + info.desc + "String_Node_Str");
thislink.setSourcePluginComment("String_Node_Str" + convertTo.getText());
thislink.setProperty("String_Node_Str",Long.valueOf(info.size));
thislink.setProperty("String_Node_Str",name + info.desc + "String_Node_Str");
thislink.setProperty("String_Node_Str",convertTo.name());
thislink.setProperty("String_Node_Str",parameter);
thislink.setProperty("String_Node_Str",true);
thislink.setProperty("String_Node_Str",info.fmt);
decryptedLinks.add(thislink);
}
}
 catch (IOException e) {
br.getHttpConnection().disconnect();
logger.log(java.util.logging.Level.SEVERE,"String_Node_Str",e);
return null;
}
}
return decryptedLinks;
}