// Path: brinbot/src/csgoscraper/Database.java
// public static int getTid(String team, String comp){
// 
//     if(comp != null && comp.contains("King of Nordic")){
//         if(team.equals("KoN Denmark") || team.equals("Denmark")){return 652;}
//         if(team.equals("KoN Norway") || team.equals("Norway")){return 654;}
//         if(team.equals("KoN Sweden") || team.equals("Sweden")){return 653;}
//         if(team.equals("KoN Finland") || team.equals("Finland")){return 655;}
//         else{return 108;}
//     }
// 
//     int tid = 108; // filler team
// 
//     Connection conn = null;
//     Statement stmt = null;
//     int active = 0;
//     String teamfix = team.replaceAll("'", "''");
//     try{
//         Class.forName("com.mysql.jdbc.Driver");
//         conn = DriverManager.getConnection(DB_URL, USER, PASS);
//         stmt = conn.createStatement();
// 
//         String sql = "SELECT tid, active FROM Teams WHERE (hltvname ='"+teamfix+"' OR name = '"+teamfix+"' OR csglname = '"+teamfix+"') LIMIT 1";
//         ResultSet rs = stmt.executeQuery(sql);
//         while(rs.next()){
//             tid = rs.getInt("tid");
//             active = rs.getInt("active");
//         }
//         rs.close();
//     }catch(SQLException se){
//         se.printStackTrace();
//     }catch(Exception e){
//         e.printStackTrace();
//     }finally{
//         try{
//             if(stmt!=null)
//                 conn.close();
//         }catch(SQLException se){
//         }
//         try{
//             if(conn!=null)
//                 conn.close();
//         }catch(SQLException se){
//             se.printStackTrace();
//         }
//         if(active == 0){markteamactive(tid);}
// 
// 
//     }
//     return tid;
// }


import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import static csgoscraper.Database.getTid;
            }


            // Scrape odds
            Elements odds = doc.select("div.match div.teamtext i");
            count = 0;
            for (Element odd : odds) {
                String scraped = odd.text();
                String scrapeodds;
                count++;
                switch (scraped.length()) {
                    case 2:  scrapeodds = scraped.substring(0,1); break;
                    case 3:  scrapeodds = scraped.substring(0,2); break;
                    case 4:  scrapeodds = scraped.substring(0,3); break;
                    default: scrapeodds = "0";
                }
                if(count % 2 != 0){scrapedodds1.add(Integer.parseInt(scrapeodds));}
                else{scrapedodds2.add(Integer.parseInt(scrapeodds));}
            }


            // Scrape competition
            Elements comps = doc.select("div.matchheader div.eventm");
            for (Element comp : comps) {
                String scraped = comp.text();
                scrapedcomps.add(scraped);
            }

            // Convert to teamids
            for(int s = 0; s < scrapedteam1.size(); s++){
// Path: brinbot/src/csgoscraper/Database.java
// public static int getTid(String team, String comp){
// 
//     if(comp != null && comp.contains("King of Nordic")){
//         if(team.equals("KoN Denmark") || team.equals("Denmark")){return 652;}
//         if(team.equals("KoN Norway") || team.equals("Norway")){return 654;}
//         if(team.equals("KoN Sweden") || team.equals("Sweden")){return 653;}
//         if(team.equals("KoN Finland") || team.equals("Finland")){return 655;}
//         else{return 108;}
//     }
// 
//     int tid = 108; // filler team
// 
//     Connection conn = null;
//     Statement stmt = null;
//     int active = 0;
//     String teamfix = team.replaceAll("'", "''");
//     try{
//         Class.forName("com.mysql.jdbc.Driver");
//         conn = DriverManager.getConnection(DB_URL, USER, PASS);
//         stmt = conn.createStatement();
// 
//         String sql = "SELECT tid, active FROM Teams WHERE (hltvname ='"+teamfix+"' OR name = '"+teamfix+"' OR csglname = '"+teamfix+"') LIMIT 1";
//         ResultSet rs = stmt.executeQuery(sql);
//         while(rs.next()){
//             tid = rs.getInt("tid");
//             active = rs.getInt("active");
//         }
//         rs.close();
//     }catch(SQLException se){
//         se.printStackTrace();
//     }catch(Exception e){
//         e.printStackTrace();
//     }finally{
//         try{
//             if(stmt!=null)
//                 conn.close();
//         }catch(SQLException se){
//         }
//         try{
//             if(conn!=null)
//                 conn.close();
//         }catch(SQLException se){
//             se.printStackTrace();
//         }
//         if(active == 0){markteamactive(tid);}
// 
// 
//     }
//     return tid;
// }


// Path: brinbot/src/csgoscraper/Csglscraper.java
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.IOException;
import java.util.ArrayList;
import static csgoscraper.Database.getTid;

            }


            // Scrape odds
            Elements odds = doc.select("div.match div.teamtext i");
            count = 0;
            for (Element odd : odds) {
                String scraped = odd.text();
                String scrapeodds;
                count++;
                switch (scraped.length()) {
                    case 2:  scrapeodds = scraped.substring(0,1); break;
                    case 3:  scrapeodds = scraped.substring(0,2); break;
                    case 4:  scrapeodds = scraped.substring(0,3); break;
                    default: scrapeodds = "0";
                }
                if(count % 2 != 0){scrapedodds1.add(Integer.parseInt(scrapeodds));}
                else{scrapedodds2.add(Integer.parseInt(scrapeodds));}
            }


            // Scrape competition
            Elements comps = doc.select("div.matchheader div.eventm");
            for (Element comp : comps) {
                String scraped = comp.text();
                scrapedcomps.add(scraped);
            }

            // Convert to teamids
            for(int s = 0; s < scrapedteam1.size(); s++){
                int stid1 = getTid(scrapedteam1.get(s), scrapedcomps.get(s));