Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ruslanys/vkmusic
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.1.1
Choose a base ref
...
head repository: ruslanys/vkmusic
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.2
Choose a head ref
  • 7 commits
  • 7 files changed
  • 1 contributor

Commits on Oct 29, 2017

  1. Release CHANGELOG

    ruslanys committed Oct 29, 2017

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    212fb1e View commit details

Commits on Nov 20, 2017

  1. Update README.md

    ruslanys authored Nov 20, 2017
    Copy the full SHA
    b89cd80 View commit details

Commits on Dec 7, 2017

  1. Update gradle wrapper

    ruslanys committed Dec 7, 2017
    Copy the full SHA
    9e4f62a View commit details
  2. Update gradle build script

    ruslanys committed Dec 7, 2017
    Copy the full SHA
    b0abb2f View commit details
  3. Copy the full SHA
    cbecaf8 View commit details
  4. Close #20

    ruslanys committed Dec 7, 2017
    Copy the full SHA
    524f699 View commit details
  5. Update CHANGELOG.md

    ruslanys committed Dec 7, 2017
    Copy the full SHA
    f15b026 View commit details
Showing with 171 additions and 165 deletions.
  1. +12 −0 CHANGELOG.md
  2. +1 −1 README.md
  3. +19 −20 build.gradle
  4. +1 −2 gradle/wrapper/gradle-wrapper.properties
  5. +84 −84 gradlew.bat
  6. +24 −9 src/main/java/me/ruslanys/vkmusic/component/impl/ScraperVkClient.java
  7. +30 −49 src/main/resources/decrypt.js
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,16 @@
и [Семантическом версионировании](http://semver.org/lang/ru/spec/v2.0.0.html).

## [Новое]

## [2.1.2] - 2017-12-08
### Исправлено
- Обновлен алгоритм дешифрации адресов mp3 файлов (#20).
- Упрощен (обновлен) Gradle скрипт сборки проекта.

### Изменено
- Gradle обновлен до 4.4.

## [2.1.1] - 2017-10-29
### Добавлено
- Установочные пакеты приложения для Windows, Unix, MacOS со встроенной JRE.
- Установлена иконка (#14).
@@ -64,5 +74,7 @@


[Новое]: https://github.com/ruslanys/vkmusic/compare/HEAD...2.x.x.SWING
[2.1.2]: https://github.com/ruslanys/vkmusic/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/ruslanys/vkmusic/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/ruslanys/vkmusic/compare/v2.0.0...v2.1.0
[2.0.0]: https://github.com/ruslanys/vkmusic/compare/e04e606...v2.0.0
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -35,4 +35,4 @@ VKMusic написан на Java 8 с применением нижеследу
* JPA/Hibernate
* SQLite
* Swing
* Java FX
* JavaFX
39 changes: 19 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
buildscript {
ext {
springBootVersion = '1.5.8.RELEASE'
jacksonVersion = '2.9.2'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
plugins {
id 'java'
id 'org.springframework.boot' version '1.5.9.RELEASE'
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

group = 'me.ruslanys'
version = '2.1.1'
version = '2.1.2'
sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
mavenCentral()
}


ext.jacksonVersion = '2.9.2'

dependencies {
// Spring
compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.boot:spring-boot-starter-cache')
compile('org.springframework.boot:spring-boot-starter-data-jpa')

// DB
compile('com.enigmabridge:hibernate4-sqlite-dialect:0.1.2')
compile('org.xerial:sqlite-jdbc:3.20.0')
compile('com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion)
compile('com.fasterxml.jackson.core:jackson-annotations:' + jacksonVersion)
compile('com.fasterxml.jackson.core:jackson-core:' + jacksonVersion)
compile('commons-cli:commons-cli:1.3.1')

// Jackson
compile("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
compile("com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion")
compile("com.fasterxml.jackson.core:jackson-core:$jacksonVersion")

// Utils
compile('commons-codec:commons-codec:1.10')
compile('org.apache.commons:commons-text:1.1')
compile('org.apache.commons:commons-lang3:3.6')
compile('com.mpatric:mp3agic:0.9.0')
compile('com.google.guava:guava:23.0')
compile('org.jsoup:jsoup:1.10.3')
compile('com.mpatric:mp3agic:0.9.0')

// DevTools
compileOnly('org.projectlombok:lombok')

// Tests
testCompile('org.springframework.boot:spring-boot-starter-test')
}

3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Oct 27 16:56:23 MSK 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
168 changes: 84 additions & 84 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@
import me.ruslanys.vkmusic.entity.Audio;
import me.ruslanys.vkmusic.exception.VkException;
import me.ruslanys.vkmusic.util.JsonUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.springframework.stereotype.Component;
@@ -17,6 +17,7 @@
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
@@ -42,8 +43,22 @@ public class ScraperVkClient implements VkClient {
private static final int SLEEP_INTERVAL = 5_000;

private final ScriptEngine scriptEngine = new ScriptEngineManager().getEngineByName("JavaScript");
private final String script;

private final Map<String, String> cookies = new HashMap<>();


public ScraperVkClient() throws IOException {
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("decrypt.js")))) {
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append(System.lineSeparator());
}
}
script = sb.toString();
}

@Override
public void addCookies(Map<String, String> cookies) {
this.cookies.putAll(cookies);
@@ -121,12 +136,13 @@ public List<Audio> getAudio(Long ownerId) {

@SneakyThrows
@Override
public void fetchUrls(List<Audio> audioList) {
public void fetchUrls(List<Audio> audioList) { // TODO: refactor
Map<Long, Audio> audioMap = new HashMap<>(audioList.size());
for (Audio audio : audioList) {
audioMap.put(audio.getId(), audio);
}

Long userId = fetchUserId();
int sleepInterval = SLEEP_INTERVAL;
int fromIndex = 0;
int toIndex = Math.min(fromIndex + 10, audioList.size());
@@ -167,7 +183,7 @@ public void fetchUrls(List<Audio> audioList) {
for (List object : lists) {
Audio audio = audioMap.get(((Number) object.get(0)).longValue());
String url = (String) object.get(2);
url = decrypt(url);
url = decrypt(userId, url);

audio.setUrl(url);
}
@@ -180,13 +196,12 @@ public void fetchUrls(List<Audio> audioList) {
}

@SneakyThrows
private String decrypt(String url) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("decrypt.js")))) {
scriptEngine.eval(bufferedReader);
private String decrypt(Long vkId, String url) {
String script = this.script.replace("${vkId}", vkId.toString()); // TODO: replace with bindings
scriptEngine.eval(script);

Invocable inv = (Invocable) scriptEngine;
return (String) inv.invokeFunction("decode", url);
}
Invocable inv = (Invocable) scriptEngine;
return (String) inv.invokeFunction("decode", url);
}

@Data
Loading