페이지를 파싱하기 어렵습니다./*
* Copyright (c) 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.services.samples.youtube.cmdline.reporting;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.services.samples.youtube.cmdline.Auth;
import com.google.api.services.youtubereporting.YouTubeReporting;
import com.google.api.services.youtubereporting.model.Job;
import com.google.api.services.youtubereporting.model.ListReportTypesResponse;
import com.google.api.services.youtubereporting.model.ReportType;
import com.google.common.collect.Lists;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
/**
* This sample creates a reporting job by:
*
* 1. Listing the available report types using the "reportTypes.list" method.
* 2. Creating a reporting job using the "jobs.create" method.
*
* @author Ibrahim Ulukaya
*/
public class CreateReportingJob {
/**
* Define a global instance of a YouTube Reporting object, which will be used to make
* YouTube Reporting API requests.
*/
private static YouTubeReporting youtubeReporting;
/**
* Create a reporting job.
*
* @param args command line args (not used).
*/
public static void main(String[] args) {
/*
* This OAuth 2.0 access scope allows for read access to the YouTube Analytics monetary reports for
* authenticated user's account. Any request that retrieves earnings or ad performance metrics must
* use this scope.
*/
List
scopes = Lists.newArrayList("https://www.googleapis.com/auth/yt-analytics-monetary.readonly");
try {
// Authorize the request.
Credential credential = Auth.authorize(scopes, "createreportingjob");
// This object is used to make YouTube Reporting API requests.
youtubeReporting = new YouTubeReporting.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential)
.setApplicationName("youtube-cmdline-createreportingjob-sample").build();
// Prompt the user to specify the name of the job to be created.
String name = getNameFromUser();
if (listReportTypes()) {
createReportingJob(getReportTypeIdFromUser(), name);
}
} catch (GoogleJsonResponseException e) {
System.err.println("GoogleJsonResponseException code: " + e.getDetails().getCode()
+ " : " + e.getDetails().getMessage());
e.printStackTrace();
} catch (IOException e) {
System.err.println("IOException: " + e.getMessage());
e.printStackTrace();
} catch (Throwable t) {
System.err.println("Throwable: " + t.getMessage());
t.printStackTrace();
}
}
/**
* Lists report types. (reportTypes.listReportTypes)
* @return true if at least one report type exists
* @throws IOException
*/
private static boolean listReportTypes() throws IOException {
// Call the YouTube Reporting API's reportTypes.list method to retrieve report types.
ListReportTypesResponse reportTypesListResponse = youtubeReporting.reportTypes().list()
.execute();
List
reportTypeList = reportTypesListResponse.getReportTypes();
if (reportTypeList == null || reportTypeList.isEmpty()) {
System.out.println("No report types found.");
return false;
} else {
// Print information from the API response.
System.out.println("\n================== Report Types ==================\n");
for (ReportType reportType : reportTypeList) {
System.out.println(" - Id: " + reportType.getId());
System.out.println(" - Name: " + reportType.getName());
System.out.println("\n-------------------------------------------------------------\n");
}
}
return true;
}
/**
* Creates a reporting job. (jobs.create)
*
* @param reportTypeId Id of the job's report type.
* @param name name of the job.
* @throws IOException
*/
private static void createReportingJob(String reportTypeId, String name)
throws IOException {
// Create a reporting job with a name and a report type id.
Job job = new Job();
job.setReportTypeId(reportTypeId);
job.setName(name);
// Call the YouTube Reporting API's jobs.create method to create a job.
Job createdJob = youtubeReporting.jobs().create(job).execute();
// Print information from the API response.
System.out.println("\n================== Created reporting job ==================\n");
System.out.println(" - ID: " + createdJob.getId());
System.out.println(" - Name: " + createdJob.getName());
System.out.println(" - Report Type Id: " + createdJob.getReportTypeId());
System.out.println(" - Create Time: " + createdJob.getCreateTime());
System.out.println("\n-------------------------------------------------------------\n");
}
/*
* Prompt the user to enter a name for the job. Then return the name.
*/
private static String getNameFromUser() throws IOException {
String name = "";
System.out.print("Please enter the name for the job [javaTestJob]: ");
BufferedReader bReader = new BufferedReader(new InputStreamReader(System.in));
name = bReader.readLine();
if (name.length()
< 1) {
// if nothing is entered, defaults to "javatestjob".
name = "javatestjob";
}
system.out.println("you chose " + name + " as the name for the job.");
return name;
}
/*
* prompt the user to enter a report type id for the job. then return the id.
*/
private static string getreporttypeidfromuser() throws ioexception {
string id = "";
system.out.print("please enter the reporttypeid for the job: ");
bufferedreader breader = new bufferedreader(new inputstreamreader(system.in));
id = breader.readline();
system.out.println("you chose " + id + " as the report type id for the job.");
return id;
}
}
1)="" {="" if="" nothing="" is="" entered,="" defaults="" to="" "javatestjob".="" name="javaTestJob" ;="" }="" system.out.println("you="" chose="" "="" +="" name="" +="" "="" as="" the="" name="" for="" the="" job.");="" return="" name;="" }="" *="" prompt="" the="" user="" to="" enter="" a="" report="" type="" id="" for="" the="" job.="" then="" return="" the="" id.="" */="" private="" static="" string="" getreporttypeidfromuser()="" throws="" ioexception="" {="" string="" id="" ;="" system.out.print("please="" enter="" the="" reporttypeid="" for="" the="" job:="" ");="" bufferedreader="" breader="new" bufferedreader(new="" inputstreamreader(system.in));="" id="bReader.readLine();" system.out.println("you="" chose="" "="" +="" id="" +="" "="" as="" the="" report="" type="" id="" for="" the="" job.");="" return="" id;="" }="" }=""> 1) {
// if nothing is entered, defaults to "javatestjob".
name = "javatestjob";
}
system.out.println("you chose " + name + " as the name for the job.");
return name;
}
/*
* prompt the user to enter a report type id for the job. then return the id.
*/
private static string getreporttypeidfromuser() throws ioexception {
string id = "";
system.out.print("please enter the reporttypeid for the job: ");
bufferedreader breader = new bufferedreader(new inputstreamreader(system.in));
id = breader.readline();
system.out.println("you chose " + id + " as the report type id for the job.");
return id;
}
}
>
- "漢字路" 한글한자자동변환 서비스는
교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는
전통문화연구회가
"울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로
공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고
다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .