Skip to content

Commit

Permalink
Merge pull request #32 from kusitms-28th-Meetup-E/feat/contents
Browse files Browse the repository at this point in the history
Feat/contents
  • Loading branch information
eojinny committed Nov 21, 2023
2 parents ad61e60 + 1086312 commit 0d0f477
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) {}
String twitterImageContent = twitterMatcher.group(1);
System.out.println(twitterImageContent);
contentsRes.setImgUrl(twitterImageContent);
contentsRepository.save(contentsMapper.toEntity(contentsRes));
updatedContentsResList.add(contentsRes);
break; // 이미지 URL을 찾았으면 더 이상 검색하지 않도록 종료
} else if (ogMatcher.find()) {
String ogImageContent = ogMatcher.group(1);
System.out.println(ogImageContent);
contentsRes.setImgUrl(ogImageContent);
contentsRepository.save(contentsMapper.toEntity(contentsRes));
updatedContentsResList.add(contentsRes);
break; // 이미지 URL을 찾았으면 더 이상 검색하지 않도록 종료
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public class ContentsController {

@GetMapping("/contents/{type}")
public ResponseEntity<SuccessResponse<List<ContentsRes>>> getYoutubeContents(@PathVariable ApiType type) throws NoSuchAlgorithmException, KeyManagementException {
// List<ContentsRes> contents = this.contentsService.getContents(type);
// imageUrlUpdateService.updateImageUrl(contents);
List<ContentsRes> contents = this.contentsService.getContents(type);
imageUrlUpdateService.updateImageUrl(contents);
return ResponseEntity.ok(SuccessResponse.create(ContentsResponseMessage.GET_CONTENTS_SUCCESS.getMessage(),this.contentsService.getContents(type)));
}

Expand Down Expand Up @@ -82,47 +82,6 @@ public ResponseEntity<SuccessResponse<List<ContentsRes>>> getContentsByLoginId(@
return ResponseEntity.ok(SuccessResponse.create(ContentsResponseMessage.GET_CONTENTS_SUCCESS.getMessage(),this.contentsService.findContentsByLoginId(socialId)));
}



// @PostMapping("/test")
// public String getContentsImg(String url) {
// try {
// // URL에서 HTML을 가져옴
// Document document = Jsoup.connect(url).get();
//
// // 메타태그 선택
// Elements metaTags = document.select("meta");
//
// // 각 메타태그의 name과 content 속성 출력
// for (Element metaTag : metaTags) {
// String name = metaTag.attr("name");
// String property = metaTag.attr("property");
// String content = metaTag.attr("content");
//
// // 정규표현식을 사용하여 twitter:image 또는 og:image의 content 속성 추출
// Pattern twitterPattern = Pattern.compile("name=\"twitter:image\"\\s*content=\"([^\"]+)\"");
// Pattern ogPattern = Pattern.compile("property=\"og:image\"\\s*content=\"([^\"]+)\"");
//
// Matcher twitterMatcher = twitterPattern.matcher(metaTag.outerHtml());
// Matcher ogMatcher = ogPattern.matcher(metaTag.outerHtml());
//
// if (twitterMatcher.find()) {
// String twitterImageContent = twitterMatcher.group(1);
// System.out.println("Twitter Image Content: " + twitterImageContent);
// } else if (ogMatcher.find()) {
// String ogImageContent = ogMatcher.group(1);
// System.out.println("OG Image Content: " + ogImageContent);
// }
// }
//
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// return null;
// }


//컨텐츠 가져오는 API
//유튜브에서 제공해주는 할당량 다 사용해서 어떻게 할지 얘기할 것.
// 진짜 조금 지원해줌 ㅜ
Expand Down

0 comments on commit 0d0f477

Please sign in to comment.