Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

50
LINES

< > BotCompany Repo | #1009890 // YouTube Live Subscriber Count [OK with key]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (7829L/55K).

!7

sS channel = "https://www.youtube.com/channel/UCSvK6EfxnMTajbe-Qpc6NvA";
static YouTubeChannelInfo info;
static JLabel lbl, lbl2, lblChannel, lblSeconds;
static JSpinner spinner;
static int seconds = 1000;
sS url = "https://console.developers.google.com/projectselector/iam-admin/iam";

p-noconsole {
  load('channel);
  final JTextField tfChannel = jtextfield(channel);
  final JTextField pfKey = jpassword(youTubeDataAPIKeyOpt());
  
  renameSubmitButton("Start Live Counter", showFormTitled("Select YouTube Channel & enter API key",
    jrightalignedlabel("Channel URL"), tfChannel,
    jrightalignedlabel("YouTube Data API Key"), pfKey,
    "", "",
    jrightalignedlabel("Get a YouTube Data API Key here:"),
      centerAndEast(juneditabletextfield(url),
        jbutton("Open", r { openBrowser(url) })),
    "", "", r {
      youTubeDataAPIKey(getTextTrim(pfKey));
      start(getTextTrim(tfChannel));
    }));
}

svoid start(S channel) {
  setAndSave(channel := channel);
  swingFontScale(2);
  info = youTubeChannelInfo(channel);
  spinner = jspinner(10, 1, 60);
  ImageSurface is = showBigText("Subscribers!", f getSubscribers, 1000).is;
  addToWindowNorth(is, lblChannel = jcenteredlabel("Channel: " + info.title));
  moveToTopRightCorner(addToWindowPack(is, vstack(lbl = jcenteredlabel(), lbl2 = jcenteredlabel(),
    withTopMargin(20, jcenteredline(jsmalllabel("Update every"), spinner, lblSeconds = jsmalllabel("seconds"))))));
}

sS[] getSubscribers() {
  int s = intFromSpinner(spinner);
  setText(lblSeconds, s == 1 ? "second" : "seconds");
  if (seconds++ < s) null;
  seconds = 0;
  YouTubeStats stats = youTubeStats(channel);
  setText(lbl, "Views: " + stats.views);
  setText(lbl2, "Videos: " + stats.videos);
  ret new S[] { n(stats.subs, "sub"), n(stats.subs, "Sub") };
}

static JLabel jsmalllabel(S text) { ret setFontSize(15, jlabel(text)); }

Author comment

Began life as a copy of #1009889

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009890
Snippet name: YouTube Live Subscriber Count [OK with key]
Eternal ID of this version: #1009890/54
Text MD5: 97bc795f659c5a6a3dae55fd79289184
Transpilation MD5: b6c161eda2d01d5dea86f7347675f054
Author: stefan
Category: javax / networking
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-24 03:39:43
Source code size: 1920 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 730 / 2667
Version history: 53 change(s)
Referenced in: [show references]