示例#1
0
  private void parsestories() {

    try {

      List<String> lns =
          Files.readAllLines(Paths.get("datasets/" + name + ".tsv"), Charset.defaultCharset());

      for (String ln : lns) stories.add(Story.fromtext(ln));

    } catch (IOException e) {

      System.out.println("Error reading dataset.");
      System.exit(1);
    }
  }
 void createStoryFromAnnotation(Story behaviours) {
   story = new StoryModel(behaviours.value());
 }
示例#3
0
  public static void main(String[] args) throws Exception {
    // Get username and password
    Scanner scanner = new Scanner(System.in);
    System.out.println("Snapchat username: "******"Snapchat password: "******"Logging in...");
    snapchat = Snapchat.login(username, password);
    if (snapchat != null) {
      System.out.println("Logged in.");
    } else {
      System.out.println("Failed to log in.");
      return;
    }

    // Ask the user what they want to do
    System.out.println();
    System.out.println("Choose an option:");
    System.out.println("\t1) Download un-viewed snaps");
    System.out.println("\t2) Send a snap");
    System.out.println("\t3) Set a Story");
    System.out.println("\t4) Download Stories");
    System.out.println();

    int option = scanner.nextInt();
    scanner.nextLine();
    switch (option) {
      case 1:
        fetchSnaps();
        break;
      case 2:
        System.out.println("Enter path to image file:");
        String snapFileName = scanner.nextLine();
        System.out.println("Enter recipient Snapchat username:"******"Enter path to image file:");
        String storyFileName = scanner.nextLine();
        setStory(username, storyFileName);
        break;
      case 4:
        Story[] storyObjs = snapchat.getStories();
        Story[] downloadable = Story.filterDownloadable(storyObjs);
        for (Story s : downloadable) {
          String extension = ".jpg";
          if (!s.isImage()) {
            extension = ".mp4";
          }
          System.out.println("Downloading story from " + s.getSender());
          byte[] storyBytes = Snapchat.getStory(s);
          File storyFile = new File(s.getSender() + "-" + s.getId() + extension);
          FileOutputStream storyOs = new FileOutputStream(storyFile);
          storyOs.write(storyBytes);
          storyOs.close();
        }
        System.out.println("Done.");
        break;
      default:
        System.out.println("Invalid option.");
        break;
    }
  }