A tool for adding anime to your anidb list.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

66 lignes
1.5KB

  1. #include <sys/stat.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <stdbool.h>
  5. #include "cmd.h"
  6. #include "error.h"
  7. #include "uio.h"
  8. #include "api.h"
  9. #include "config.h"
  10. #include "ed2k_util.h"
  11. #include "cache.h"
  12. #include "util.h"
  13. enum error cmd_modify(void *data)
  14. {
  15. struct api_mylistadd_opts mopt = {0};
  16. bool *watched;
  17. const char **wdate_str;
  18. enum error err = NOERR;
  19. int fcount;
  20. fcount = config_get_nonopt_count();
  21. if (fcount == 0) {
  22. uio_error("No mylist ids specified");
  23. return ERR_CMD_ARG;
  24. }
  25. if (config_get("watched", (void**)&watched) == NOERR && *watched) {
  26. mopt.watched = *watched;
  27. mopt.watched_set = true;
  28. if (config_get("wdate", (void**)&wdate_str) == NOERR) {
  29. uint64_t wdate = util_iso2unix(*wdate_str);
  30. if (wdate == 0) {
  31. uio_error("Invalid time value: '%s'", *wdate_str);
  32. return ERR_CMD_ARG;
  33. }
  34. mopt.wdate = wdate;
  35. mopt.wdate_set = true;
  36. }
  37. }
  38. for (int i = 0; i < fcount; i++) {
  39. struct api_result res;
  40. uint64_t lid;
  41. const char *arg = config_get_nonopt(i);
  42. if (sscanf(arg, "%lu", &lid) != 1) {
  43. uio_error("Argument '%s' is not an integer. Skipping", arg);
  44. continue;
  45. }
  46. err = api_cmd_mylistmod(lid, &mopt, &res);
  47. if (err != NOERR)
  48. break;
  49. if (res.code == APICODE_NO_SUCH_MYLIST_ENTRY) {
  50. uio_error("No mylist entry with id: '%lu'", lid);
  51. }
  52. }
  53. return err;
  54. }