Skip to content

Commit

Permalink
chore: basic youtube search
Browse files Browse the repository at this point in the history
  • Loading branch information
64ArthurAraujo committed Jan 27, 2024
1 parent 5309225 commit 09d3e8b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
27 changes: 23 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
<artifactId>wordview</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>WordViewAPI</name>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -105,11 +113,22 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>

<dependency>
<groupId>cc.wordview</groupId>
<artifactId>ytm</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/home/arthur/repos/wv-ytm/ytm/target/ytm-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
</dependency>
</dependencies>

<build>
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/cc/wordview/api/controller/MusicController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cc.wordview.api.controller;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.wordview.api.Constants;
import cc.wordview.ytm.YoutubeApi;
import cc.wordview.ytm.response.SearchResult;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@RestController
@CrossOrigin(origins = Constants.CORS_ORIGIN)
@RequestMapping(path = Constants.REQUEST_PATH + "/music")
public class MusicController {
@Value("${wordview.ytm.api-key}")
private String API_KEY;

private YoutubeApi api = new YoutubeApi();

@GetMapping("/search")
public List<SearchResult> search(@RequestParam String q) throws IOException {
List<SearchResult> results = api.search(q, 10, API_KEY);
return results;
}
}

0 comments on commit 09d3e8b

Please sign in to comment.