Advertisement
ec1117

Youtube Watch Later Converter

Aug 29th, 2022 (edited)
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2. using namespace std;
  3.  
  4. bool isTimestamp(string S){
  5.     bool numOnly=true;
  6.     for(char x:S)
  7.         if(x<'0' || x>'9')
  8.             if(x!=':')
  9.                 numOnly=false;
  10.  
  11.     return S.find(":") != string::npos && numOnly;
  12. }
  13. void solve(){
  14.     while(true){
  15.         string line;
  16.         getline(cin,line);
  17.         if(isTimestamp(line)){
  18.             string videoTime = line;
  19.             getline(cin,line);//"NOW PLAYING"
  20.             getline(cin,line);
  21.             string videoTitle = "\"" + line + "\"";
  22.             getline(cin,line);
  23.             string videoCreator = "\"" + line + "\"";
  24.             cout << videoTime << "," << videoTitle << "," << videoCreator << '\n';
  25.         }
  26.         else if(line.size()){
  27.             string videoTitle = "\"" + line + "\"";
  28.             getline(cin,line);
  29.             string videoCreator = "\"" + line + "\"";
  30.             cout << "" << "," << videoTitle << "," << videoCreator << '\n';
  31.         }
  32.     }
  33. }
  34.  
  35. int main(){
  36.     freopen("tmp.in","r",stdin);
  37.     freopen("tmp.out","w",stdout);
  38.     solve();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement