Skip to content

Commit

Permalink
youtube id extractor, named parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-diver committed May 31, 2021
1 parent 59335f1 commit 88f97a5
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
3 changes: 2 additions & 1 deletion client/lib/detail.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:youtube_player_flutter/youtube_player_flutter.dart';
import 'package:pr12er/utils/extractor.dart';

class DetailApp extends StatelessWidget {
late String url;

DetailApp(String url) {
this.url = url;
this.url = Extractor.extractYoutubeId(url);
}

@override
Expand Down
21 changes: 12 additions & 9 deletions client/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,22 @@ class _ClientState extends State<Client> {
padding: const EdgeInsets.all(8),
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
return getTile(
index,
snapshot.data[index].title,
snapshot.data[index].presenter,
"현재 키워드 지원(X)",
snapshot.data[index].category,
snapshot.data[index].link);
return getTile(index,
title: snapshot.data[index].title,
presenter: snapshot.data[index].presenter,
keyword: "현재 키워드 지원(X)",
category: snapshot.data[index].category,
url: snapshot.data[index].link);
});
});
}

Widget getTile(int index, String title, String presenter, String keyword,
Category category, String url) {
Widget getTile(int index,
{String title = "",
String presenter = "",
String keyword = "",
Category category = Category.CATEGORY_UNSPECIFIED,
String url = ""}) {
return Card(
child: ListTile(
leading: Column(
Expand Down
24 changes: 12 additions & 12 deletions client/lib/test-server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,88 +15,88 @@ class GreeterService extends Pr12erServiceBase {
List<Video> videos = <Video>[
Video(
id: 1,
link: "L3hz57whyNw",
link: "https://youtu.be/L3hz57whyNw",
numberOfLike: 10,
presenter: "유재준",
title: "Generative Adversarial Nets",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "RRwaz0fBQ0Y",
link: "https://youtu.be/RRwaz0fBQ0Y",
numberOfLike: 10,
presenter: "엄태웅",
title: "Deformable Convolutional Networks",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "_Dp8u97_rQ0",
link: "https://youtu.be/_Dp8u97_rQ0",
numberOfLike: 10,
presenter: "곽근봉",
title:
"Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation",
category: Category.CATEGORY_NLP),
Video(
id: 1,
link: "1jGr_OFyfa0",
link: "https://youtu.be/1jGr_OFyfa0",
numberOfLike: 10,
presenter: "전태균",
title:
"Image Super-Resolution using Deep Convolutional Neural Networks",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "V7_cNTfm2i8",
link: "https://youtu.be/V7_cNTfm2i8",
numberOfLike: 10,
presenter: "김성훈",
title: "Playing Atari with Deep Reinforcement Learning",
category: Category.CATEGORY_UNSPECIFIED),
Video(
id: 1,
link: "2wbDiZCWQtY",
link: "https://youtu.be/2wbDiZCWQtY",
numberOfLike: 10,
presenter: "서기호",
title: "Neural Turing Machines",
category: Category.CATEGORY_UNSPECIFIED),
Video(
id: 1,
link: "YF6nLVDlznE",
link: "https://youtu.be/YF6nLVDlznE",
numberOfLike: 10,
presenter: "김승일",
title: "Deep Photo Style Transfer",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "jbnjzyJDldA",
link: "https://youtu.be/jbnjzyJDldA",
numberOfLike: 10,
presenter: "정동준",
title:
"Reverse Classification Accuracy: Predicting Segmentation Performance in the Absence of Ground Truth",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "tOItokBZSfU",
link: "https://youtu.be/tOItokBZSfU",
numberOfLike: 10,
presenter: "정영재",
title: "Distilling the Knowledge in a Neural Network",
category: Category.CATEGORY_UNSPECIFIED),
Video(
id: 1,
link: "KYA-GEhObIs",
link: "https://youtu.be/KYA-GEhObIs",
numberOfLike: 10,
presenter: "차준범",
title: "Auto-Encoding Variational Bayes",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "kcPAGIgBGRs",
link: "https://youtu.be/kcPAGIgBGRs",
numberOfLike: 10,
presenter: "이진원",
title:
"Faster R-CNN: Towards Real-time Object Detection with Region Proposal Networks",
category: Category.CATEGORY_VISION),
Video(
id: 1,
link: "n2J7giHrS-Y",
link: "https://youtu.be/n2J7giHrS-Y",
numberOfLike: 10,
presenter: "유재준",
title: "Domain Adversarial Training of Neural Network",
Expand Down
6 changes: 6 additions & 0 deletions client/lib/utils/extractor.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Extractor {
static String extractYoutubeId(String url) {
final int index = url.lastIndexOf('/');
return url.substring(index + 1);
}
}
7 changes: 7 additions & 0 deletions client/test/main_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pr12er/main.dart';
import 'package:pr12er/utils/extractor.dart';

void main() {
testWidgets('MainWidget has a load view', (WidgetTester tester) async {
Expand All @@ -12,4 +13,10 @@ void main() {
final titleFinder = find.text('pr12errrrrrrrrrrrrrrrrrrr');
expect(titleFinder, findsOneWidget);
});

test('only id from youtube url should be extracted', () {
final url = "https://youtu.be/V7_cNTfm2i8";
String extractedId = Extractor.extractYoutubeId(url);
expect("V7_cNTfm2i8", extractedId);
});
}

0 comments on commit 88f97a5

Please sign in to comment.