├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── drawable-v24
│ │ │ └── ic_launcher_foreground.xml
│ │ ├── layout
│ │ │ ├── activity_second.xml
│ │ │ └── activity_main.xml
│ │ └── drawable
│ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── sanjaydevtech
│ │ └── instarepost
│ │ ├── SecondActivity.java
│ │ └── MainActivity.kt
├── proguard-rules.pro
└── build.gradle
├── .gitattributes
├── .idea
├── .name
├── vcs.xml
├── compiler.xml
├── kotlinc.xml
├── dictionaries
│ └── admin_pc.xml
├── misc.xml
├── deploymentTargetDropDown.xml
├── gradle.xml
├── jarRepositories.xml
├── markdown-navigator.xml
├── codeStyles
│ └── Project.xml
└── markdown-navigator-enh.xml
├── instautils
├── .gitignore
├── consumer-rules.pro
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ └── com
│ │ └── sanjaydevtech
│ │ └── instautils
│ │ ├── InstaTask.kt
│ │ ├── InstaImage.kt
│ │ ├── InstaResponse.kt
│ │ ├── InstaPost.kt
│ │ ├── InstaScraper.kt
│ │ └── InstaDownloader.kt
├── proguard-rules.pro
└── build.gradle
├── jitpack.yml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── settings.gradle
├── LICENSE
├── CHANGELOG.md
├── gradle.properties
├── .travis.yml
├── gradlew.bat
├── README.md
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | InstagramRepost
--------------------------------------------------------------------------------
/instautils/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/instautils/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | jdk:
2 | - openjdk17
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | InstagramRepost
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SanjayDevTech/instautils/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/instautils/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/instautils/src/main/java/com/sanjaydevtech/instautils/InstaTask.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instautils
2 |
3 | /**
4 | * InstaTask to hold the result of network
5 | */
6 | data class InstaTask(val instaPost: InstaPost?, val exception: Exception?)
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 29 00:07:24 IST 2023
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/.idea/dictionaries/admin_pc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | insta
5 | instagram
6 | instapp
7 | mozilla
8 | sanjay
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/instautils/src/main/java/com/sanjaydevtech/instautils/InstaImage.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instautils
2 |
3 | import android.graphics.Bitmap
4 |
5 | /** InstaImage
6 | */
7 | fun interface InstaImage {
8 | /**
9 | * OnBitmap loaded
10 | *
11 | * @param bitmap bitmap from a image post
12 | */
13 | fun onBitmapLoaded(bitmap: Bitmap)
14 | }
--------------------------------------------------------------------------------
/instautils/src/main/java/com/sanjaydevtech/instautils/InstaResponse.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instautils
2 |
3 | /**
4 | * InstaResponse to handle download url searching
5 | */
6 | fun interface InstaResponse {
7 | /**
8 | * On completion of url searching
9 | *
10 | * @param instaTask InstaTask object which holds the post or exception
11 | */
12 | fun onResponse(instaTask: InstaTask)
13 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "InstagramRepost"
16 | include ':app'
17 | include ':instautils'
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/instautils/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/instautils/src/main/java/com/sanjaydevtech/instautils/InstaPost.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instautils
2 |
3 | /**
4 | * InstaPost Object
5 | *
6 | * [url] holds the actual image or video url
7 | *
8 | * [type] may be constants [INSTA_IMAGE] or [INSTA_VIDEO] or [INSTA_PROFILE]
9 | *
10 | * [thumbnailUrl] is the same as url for type [INSTA_IMAGE],
11 | * but a low res image for [INSTA_VIDEO] and [INSTA_PROFILE]
12 | */
13 | data class InstaPost internal constructor(
14 | val url: String,
15 | val type: Int,
16 | val thumbnailUrl: String) {
17 |
18 | companion object {
19 | /** InstaPost object is from a Image */
20 | const val INSTA_IMAGE = 0
21 |
22 | /** InstaPost object is from a Video */
23 | const val INSTA_VIDEO = 1
24 |
25 | /** InstaPost object is from a Instagram Profile */
26 | const val INSTA_PROFILE = 2
27 | }
28 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Sanjay Developer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'kotlin-android'
4 | }
5 | android {
6 | compileSdk 34
7 |
8 | defaultConfig {
9 | applicationId "com.sanjaydevtech.instarepost"
10 | minSdk 16
11 | targetSdk 34
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | namespace "com.sanjaydevtech.instarepost"
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_17
27 | targetCompatibility JavaVersion.VERSION_17
28 | }
29 | kotlinOptions {
30 | jvmTarget = '17'
31 | }
32 | }
33 |
34 | dependencies {
35 | implementation 'androidx.core:core-ktx:1.12.0'
36 | implementation 'androidx.appcompat:appcompat:1.6.1'
37 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
38 | implementation project(':instautils')
39 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
5 | - `Added` for new features.
6 | - `Changed` for changes in existing functionality.
7 | - `Deprecated` for soon-to-be removed features.
8 | - `Removed` for now removed features.
9 | - `Fixed` for any bug fixes.
10 | - `Security` in case of vulnerabilities.
11 |
12 | ***
13 | ## [1.2.3] - 27/10/2023
14 | ### Changed
15 | - Removed JFrog publish configurations and moved to jitpack.io
16 | - Upgraded the java version to 17
17 | - Upgraded the gradle and dependency versions
18 |
19 | ***
20 |
21 | ## [1.2.0] - 07/01/2021
22 | ### Changed
23 | - Moved all methods to InstaDownloader class to unify apis
24 |
25 | ***
26 |
27 | ## [1.1.0] - 06/01/2021
28 | ### Added
29 | - Support for fragments
30 |
31 | ### Changed
32 | - AsyncTask to Kotlin Coroutines
33 |
34 | ***
35 |
36 | ## [1.0.2] - 07/09/2020
37 | ### Added
38 | - Can fetch Instagram DP
39 |
40 | ***
41 |
42 | ## [1.0.1] - 06/09/2020
43 | ### Added
44 | - Can get both image and video download links
45 |
46 | ### Changed
47 | - Approached a new efficient method to retrieve the link
48 |
49 | ***
50 |
51 | ## [1.0.0] - 06/09/2020
52 | ### Added
53 | - Get the direct download link for image post
54 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
24 | android.defaults.buildfeatures.buildconfig=true
25 | android.nonFinalResIds=false
26 | org.gradle.unsafe.configuration-cache=true
--------------------------------------------------------------------------------
/instautils/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | id 'kotlin-android'
4 | id 'maven-publish'
5 | }
6 |
7 | android {
8 | compileSdk 34
9 |
10 | defaultConfig {
11 | minSdk 16
12 | targetSdk 34
13 |
14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
15 | consumerProguardFiles "consumer-rules.pro"
16 | }
17 |
18 | buildTypes {
19 | release {
20 | minifyEnabled false
21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22 | }
23 | }
24 | namespace 'com.sanjaydevtech.instautils'
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_17
27 | targetCompatibility JavaVersion.VERSION_17
28 | }
29 | kotlinOptions {
30 | jvmTarget = '17'
31 | }
32 | }
33 | afterEvaluate {
34 | publishing {
35 | publications {
36 | release(MavenPublication) {
37 | groupId = project.group
38 | artifactId = 'instautils'
39 | version = project.version
40 | from components.release
41 | }
42 | }
43 | }
44 | }
45 | dependencies {
46 | implementation 'androidx.core:core-ktx:1.12.0'
47 | api "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1"
48 | api "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1"
49 | api "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
50 | implementation 'androidx.appcompat:appcompat:1.6.1'
51 | implementation 'com.github.bumptech.glide:glide:4.11.0'
52 | implementation 'org.jsoup:jsoup:1.11.2'
53 | }
54 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: android
2 |
3 | jdk: oraclejdk8
4 |
5 | sudo: false
6 |
7 | before_cache:
8 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
9 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
10 |
11 | cache:
12 | directories: #Cache all dirs under .gradle folder
13 | - $HOME/.gradle/daemon #Cache daemon logs
14 | - $HOME/.gradle/native #Cache library downloaded from the gradle dependency
15 | - $HOME/.gradle/wrapper #Cache the gradle
16 |
17 | android:
18 | components:
19 | - tools
20 | - platform-tools
21 | - android-22
22 | - sys-img-armeabi-v7a-android-22
23 |
24 | # Additional components
25 | - extra-google-google_play_services
26 | - extra-google-m2repository
27 | - extra-android-m2repository
28 |
29 | licenses:
30 | - 'android-sdk-preview-license-52d11cd2'
31 | - 'android-sdk-license-.+'
32 | - 'google-gdk-license-.+'
33 |
34 | before_install:
35 | - mkdir "$ANDROID_HOME/licenses" || true
36 | - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
37 | - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
38 | - chmod +x gradlew
39 | - echo ${ANDROID_HOME}
40 | - echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager "platforms;android-30"
41 | - echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;30.0.2"
42 | - echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager "extras;android;m2repository"
43 | - echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager "extras;google;m2repository"
44 | - export LANG=en_US.UTF-8
45 |
46 | script:
47 | - ./gradlew clean build
48 |
49 | deploy:
50 | provider: script
51 | script: ./gradlew bintrayUpload
52 |
53 | on:
54 | tags: true
55 | branch: master
56 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
22 |
23 |
33 |
34 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
22 |
23 |
33 |
34 |
44 |
45 |
57 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Insta Utils
2 |
3 | ## Archived
4 | Please check [Issue #7](https://github.com/SanjayDevTech/instautils/issues/7)
5 |
6 | Insta Utils is a Insta post downloader for Android applications written in **Java**.
7 |
8 | [](https://travis-ci.com/SanjayDevTech/instautils)
9 | [ ](https://bintray.com/sanjaydevtech/instautils/com.sanjaydevtech.instautils/_latestVersion)
10 |
11 | ## New Features!
12 | Check [CHANGELOG](https://github.com/SanjayDevTech/instautils/blob/master/CHANGELOG.md) for new features and updates
13 |
14 |
15 | ## Credits
16 |
17 | Insta Utils uses a number of open source libraries to work properly:
18 |
19 | - JSoup - To parse HTML
20 | - [Glide](https://github.com/bumptech/glide) - Url to ImageView
21 |
22 | ## Implementation
23 | ### Project level
24 | ```gradle
25 | dependencyResolutionManagement {
26 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
27 | repositories {
28 | mavenCentral()
29 | maven { url 'https://jitpack.io' }
30 | }
31 | }
32 | ```
33 |
34 | ### App level
35 | ```gradle
36 | implementation 'com.github.SanjayDevTech:instautils:'
37 | ```
38 | Check [Releases](https://github.com/SanjayDevTech/instautils/releases) for Latest version
39 |
40 |
41 | ## Usage
42 |
43 | ### Initialize InstaDownloader
44 | ```java
45 | InstaDownloader downloader = new InstaDownloader(this, new InstaResponse() {
46 | @Override
47 | public void onResponse(@NotNull InstaTask instaTask) {
48 | // Retrieve post instance from InstaTask
49 | InstaPost instaPost = instaTask.getInstaPost();
50 |
51 | if (instaPost != null) {
52 | // InstaPost has something in it
53 |
54 | // Log the direct url
55 | Log.d(TAG, instaPost.getUrl());
56 |
57 | // set the post object to ImageView
58 | downloader.setImage(instaPost, displayImageView);
59 |
60 | // Log the type (0 => Image, 1 => Video or 2 => Profile)
61 | Log.d(TAG, "Type: " + instaPost.getType());
62 | } else {
63 | // Log the error
64 | instaTask.getException().printStackTrace();
65 | }
66 | }
67 | });
68 | ```
69 |
70 |
71 | ### Instagram profile
72 | ```java
73 | String instaProfileUrl = "https://instagram.com/SanjayDevTech";
74 | downloader.getDP(instaProfileUrl);
75 | ```
76 |
77 | ### Instagram Image/Video
78 | ```java
79 | String instaPostUrl = "https://www.instagram.com/p/post_id/";
80 | downloader.get(instaPostUrl);
81 | ```
82 |
83 |
84 | ## Any Issues?
85 | * Create a new issue on github
86 | * Pull requests are welcomed 😀
87 |
88 |
89 | ## License
90 | ----
91 | MIT
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/sanjaydevtech/instarepost/SecondActivity.java:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instarepost;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 | import android.widget.Button;
6 | import android.widget.EditText;
7 | import android.widget.ImageView;
8 | import android.widget.Toast;
9 |
10 | import androidx.appcompat.app.AppCompatActivity;
11 |
12 | import com.sanjaydevtech.instautils.InstaDownloader;
13 | import com.sanjaydevtech.instautils.InstaPost;
14 | import com.sanjaydevtech.instautils.InstaResponse;
15 | import com.sanjaydevtech.instautils.InstaScraper;
16 | import com.sanjaydevtech.instautils.InstaTask;
17 |
18 | import org.jetbrains.annotations.NotNull;
19 |
20 | import java.util.regex.Matcher;
21 | import java.util.regex.Pattern;
22 |
23 | public class SecondActivity extends AppCompatActivity {
24 |
25 | private InstaDownloader downloader; // Declare the InstaDownloader
26 | private static final String TAG = MainActivity.class.getSimpleName();
27 | private static final String URL_PATTERN = "^https://www.instagram.com/p/.+";
28 | private static final String DP_URL_PATTERN = "^(https://(www\\.)?instagram\\.com/[^p][0-9a-zA-Z_.]+)";
29 | private ImageView img;
30 |
31 | @Override
32 | protected void onCreate(Bundle savedInstanceState) {
33 | super.onCreate(savedInstanceState);
34 | setContentView(R.layout.activity_second);
35 |
36 | downloader = new InstaDownloader(this, instaTask ->
37 | onResponseMethod(instaTask)
38 | );
39 |
40 | final EditText urlTxt = findViewById(R.id.urlTxt);
41 | final Button doneBtn = findViewById(R.id.doneBtn);
42 | img = findViewById(R.id.imageView);
43 |
44 | doneBtn.setOnClickListener(view -> {
45 | Pattern pattern = Pattern.compile(URL_PATTERN);
46 | Matcher matcher = pattern.matcher(urlTxt.getText().toString());
47 | if (matcher.find()) {
48 | downloader.get(urlTxt.getText().toString()); // Request the post data
49 | } else {
50 | pattern = Pattern.compile(DP_URL_PATTERN);
51 | matcher = pattern.matcher(urlTxt.getText().toString());
52 | if (matcher.find()) {
53 | downloader.getDP(urlTxt.getText().toString());
54 | } else {
55 | Toast.makeText(SecondActivity.this, "Invalid insta url", Toast.LENGTH_SHORT).show();
56 | }
57 | }
58 |
59 | });
60 |
61 | }
62 |
63 | private void onResponseMethod(@NotNull InstaTask instaTask) {
64 | InstaPost instaPost = instaTask.getInstaPost();
65 | if (instaPost != null) {
66 | Log.d(TAG, instaPost.getUrl());
67 | // Retrieve the post object after request
68 | downloader.setImage(instaPost, img);
69 | Log.d(TAG, "Type: " + instaPost.getType());
70 | } else {
71 | instaTask.getException().printStackTrace();
72 | }
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/sanjaydevtech/instarepost/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instarepost
2 |
3 | import android.content.Intent
4 | import android.os.Bundle
5 | import android.util.Log
6 | import android.widget.Button
7 | import android.widget.EditText
8 | import android.widget.ImageView
9 | import android.widget.Toast
10 | import androidx.appcompat.app.AppCompatActivity
11 | import com.sanjaydevtech.instautils.InstaDownloader
12 | import com.sanjaydevtech.instautils.InstaScraper
13 | import com.sanjaydevtech.instautils.InstaTask
14 | import java.util.regex.Pattern
15 |
16 | class MainActivity : AppCompatActivity() {
17 | private lateinit var downloader: InstaDownloader
18 | private lateinit var img: ImageView
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 | setContentView(R.layout.activity_main)
23 |
24 | downloader = InstaDownloader(this) { instaTask ->
25 | onResponse(instaTask)
26 | }
27 |
28 | val urlTxt: EditText = findViewById(R.id.urlTxt)
29 | val doneBtn: Button = findViewById(R.id.doneBtn)
30 | val testBtn: Button = findViewById(R.id.test_btn)
31 | img = findViewById(R.id.imageView)
32 |
33 | testBtn.setOnClickListener {
34 | val intent = Intent(this, SecondActivity::class.java)
35 | startActivity(intent)
36 | }
37 |
38 | doneBtn.setOnClickListener {
39 | var pattern = Pattern.compile(URL_PATTERN)
40 | var matcher = pattern.matcher(urlTxt.text.toString())
41 | if (matcher.find()) {
42 | // If the given url is a post
43 | downloader.get(urlTxt.text.toString()) // Request the post data
44 | } else {
45 | // if the given url is not a post
46 | pattern = Pattern.compile(DP_URL_PATTERN)
47 | matcher = pattern.matcher(urlTxt.text.toString())
48 | if (matcher.find()) {
49 | // if the given url is a profile
50 | downloader.getDP(urlTxt.text.toString())
51 | } else {
52 | // The url is invalid
53 | Toast.makeText(this@MainActivity, "Invalid insta url", Toast.LENGTH_SHORT).show()
54 | }
55 | }
56 | }
57 | }
58 |
59 | private fun onResponse(instaTask: InstaTask) {
60 | val instaPost = instaTask.instaPost
61 | if (instaPost != null) {
62 | Log.d(TAG, instaPost.url)
63 | // Retrieve the post object after request
64 | downloader.setImage(instaPost, img)
65 | Log.d(TAG, "Type: " + instaPost.type)
66 | } else {
67 | instaTask.exception!!.printStackTrace()
68 | }
69 | }
70 |
71 | companion object {
72 | private val TAG = MainActivity::class.java.simpleName
73 | private const val URL_PATTERN = "^https://www.instagram.com/p/.+"
74 | private const val DP_URL_PATTERN = "^(https://(www\\.)?instagram\\.com/[^p][0-9a-zA-Z_.]+)"
75 | }
76 | }
--------------------------------------------------------------------------------
/.idea/markdown-navigator.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/instautils/src/main/java/com/sanjaydevtech/instautils/InstaScraper.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instautils
2 |
3 | import androidx.fragment.app.Fragment
4 | import androidx.fragment.app.FragmentActivity
5 | import androidx.lifecycle.lifecycleScope
6 | import kotlinx.coroutines.CoroutineScope
7 | import kotlinx.coroutines.Dispatchers
8 | import kotlinx.coroutines.launch
9 | import kotlinx.coroutines.withContext
10 | import org.jsoup.Jsoup
11 | import java.io.IOException
12 | import java.util.regex.Pattern
13 |
14 | /**
15 | * InstaScraper class for downloading dp
16 | */
17 | @Deprecated("Use InstaDownloader.getDP()")
18 | object InstaScraper {
19 | private const val DP_URL = "^(https://(www\\.)?instagram\\.com/[0-9a-zA-Z_.]+)"
20 | private const val NOISE = "\\u0026"
21 | private const val PROFILE_HD_PATTERN = "\"profile_pic_url_hd\":\"([^\"]*)\""
22 | private const val PROFILE_PATTERN = "\"profile_pic_url\":\"([^\"]*)\""
23 |
24 | /**
25 | * To retrieve Instagram profile
26 | *
27 | * @param activity Activity
28 | * @param url Url of the instagram profile
29 | * @param response InstaResponse instance
30 | */
31 | @JvmStatic
32 | fun getDP(activity: FragmentActivity, url: String, response: InstaResponse) {
33 | getDP(activity.lifecycleScope, url, response)
34 | }
35 |
36 | /**
37 | * To retrieve Instagram profile
38 | *
39 | * @param fragment Fragment
40 | * @param url Url of the instagram profile
41 | * @param response InstaResponse instance
42 | */
43 | @JvmStatic
44 | fun getDP(fragment: Fragment, url: String, response: InstaResponse) {
45 | getDP(fragment.viewLifecycleOwner.lifecycleScope, url, response)
46 | }
47 |
48 |
49 | @JvmStatic
50 | private fun getDP(scope: CoroutineScope, url: String, response: InstaResponse) {
51 | scope.launch(Dispatchers.IO) {
52 | try {
53 | val document = Jsoup.connect(url).userAgent("Mozilla/5.0").get()
54 | val scripts = document.getElementsByTag("script")
55 | for (script in scripts) {
56 | for (dataNode in script.dataNodes()) {
57 | val scriptData = dataNode.wholeData.trim { it <= ' ' }
58 | if (scriptData.startsWith("window._sharedData")) {
59 | var profilePicHD = matchPattern(scriptData, PROFILE_HD_PATTERN)
60 | var profilePic = matchPattern(scriptData, PROFILE_PATTERN)
61 | if (profilePicHD != null) {
62 | profilePicHD = profilePicHD.replace(NOISE, "&")
63 | }
64 | if (profilePic != null) {
65 | profilePic = profilePic.replace(NOISE, "&")
66 | }
67 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(InstaPost(profilePicHD!!, InstaPost.INSTA_PROFILE, profilePic!!), null)) }
68 | return@launch
69 | }
70 | }
71 | }
72 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, IllegalArgumentException("No data resource found"))) }
73 |
74 | } catch (e: IOException) {
75 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, e)) }
76 | }
77 | }
78 | }
79 |
80 | private fun matchPattern(data: String, patTxt: String): String? {
81 | val pattern = Pattern.compile(patTxt)
82 | val matcher = pattern.matcher(data)
83 | val patMatch = matcher.find()
84 | return if (!patMatch) {
85 | null
86 | } else matcher.group(1)
87 | }
88 | }
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator-enh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/instautils/src/main/java/com/sanjaydevtech/instautils/InstaDownloader.kt:
--------------------------------------------------------------------------------
1 | package com.sanjaydevtech.instautils
2 |
3 | import android.content.Context
4 | import android.graphics.Bitmap
5 | import android.graphics.drawable.Drawable
6 | import android.util.Log
7 | import android.widget.ImageView
8 | import androidx.fragment.app.Fragment
9 | import androidx.fragment.app.FragmentActivity
10 | import androidx.lifecycle.lifecycleScope
11 | import com.bumptech.glide.Glide
12 | import com.bumptech.glide.request.target.CustomTarget
13 | import com.bumptech.glide.request.transition.Transition
14 | import kotlinx.coroutines.CoroutineScope
15 | import kotlinx.coroutines.Dispatchers
16 | import kotlinx.coroutines.launch
17 | import kotlinx.coroutines.withContext
18 | import org.jsoup.Jsoup
19 | import java.io.IOException
20 | import java.util.regex.Pattern
21 |
22 | /**
23 | * Downloader Class to download insta posts
24 | *
25 | * @author Sanjay Developer
26 | * @version 1.2.0
27 | */
28 | class InstaDownloader internal constructor(private val context: Context?, private val scope: CoroutineScope, private val response: InstaResponse) {
29 |
30 | constructor(activity: FragmentActivity, response: InstaResponse) : this(activity, activity.lifecycleScope, response)
31 | constructor(fragment: Fragment, response: InstaResponse) : this(fragment.context, fragment.viewLifecycleOwner.lifecycleScope, response)
32 |
33 | /**
34 | * Get the url of the post
35 | *
36 | * @param url URL of that post
37 | */
38 | fun get(url: String) {
39 | scope.launch(Dispatchers.IO) {
40 | try {
41 | val document = Jsoup.connect(url).userAgent("Mozilla/5.0").get()
42 | val metas = document.getElementsByTag("meta")
43 | var img: String? = null
44 | var vid: String? = null
45 | var type: String? = null
46 | for (meta in metas) {
47 | val property = meta.attr("property")
48 | if (property == "og:image") {
49 | img = meta.attr("content")
50 | continue
51 | }
52 | if (property == "og:video") {
53 | vid = meta.attr("content")
54 | continue
55 | }
56 | if (property == "og:type") {
57 | type = meta.attr("content")
58 | }
59 | }
60 | if (type == null || type != "video" && type != "instapp:photo") {
61 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, IllegalArgumentException("No data resource found"))) }
62 | } else {
63 | if (type == "instapp:photo") {
64 | if (img != null) {
65 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(InstaPost(img, InstaPost.INSTA_IMAGE, img), null)) }
66 | } else {
67 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, IllegalArgumentException("No data resource found"))) }
68 | }
69 | } else {
70 | if (img != null && vid != null) {
71 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(InstaPost(vid, InstaPost.INSTA_VIDEO, img), null)) }
72 | } else {
73 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, IllegalArgumentException("No data resource found"))) }
74 | }
75 | }
76 | }
77 | } catch (e: IOException) {
78 | e.printStackTrace()
79 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, e)) }
80 | }
81 | }
82 | }
83 |
84 | /**
85 | * Retrieve the bitmap of the image post or thumbnail of video post
86 | *
87 | * @param post InstaPost object retrieved from InstaResponse
88 | * @param instaImage Listener to handle bitmap
89 | */
90 | fun getBitmap(post: InstaPost, instaImage: InstaImage) {
91 | val imgUrl = post.thumbnailUrl
92 | context?.let {
93 | Glide.with(it)
94 | .asBitmap()
95 | .load(imgUrl)
96 | .into(object : CustomTarget() {
97 | override fun onResourceReady(resource: Bitmap, transition: Transition?) {
98 | instaImage.onBitmapLoaded(resource)
99 | }
100 |
101 | override fun onLoadCleared(placeholder: Drawable?) {}
102 | })
103 | } ?: run {
104 | Log.e(TAG, "method: getBitmap can't set image.. [REASON] Context is null")
105 | }
106 | }
107 |
108 | /**
109 | * Post to ImageView
110 | *
111 | * @param post InstaPost object
112 | * @param imageView To which view that image has to set
113 | */
114 | fun setImage(post: InstaPost, imageView: ImageView) {
115 | val imgUrl = post.thumbnailUrl
116 | context?.let {
117 | Glide.with(it)
118 | .load(imgUrl)
119 | .into(imageView)
120 | } ?: run {
121 | Log.e(TAG, "method: setImage can't set image.. [REASON] Context is null")
122 | }
123 | }
124 |
125 | /**
126 | * To retrieve Instagram profile
127 | *
128 | * @param url Url of the instagram profile
129 | */
130 | fun getDP(url: String) {
131 | scope.launch(Dispatchers.IO) {
132 | try {
133 | val document = Jsoup.connect(url).userAgent("Mozilla/5.0").get()
134 | val scripts = document.getElementsByTag("script")
135 | for (script in scripts) {
136 | for (dataNode in script.dataNodes()) {
137 | val scriptData = dataNode.wholeData.trim { it <= ' ' }
138 | if (scriptData.startsWith("window._sharedData")) {
139 | var profilePicHD = matchPattern(scriptData, PROFILE_HD_PATTERN)
140 | var profilePic = matchPattern(scriptData, PROFILE_PATTERN)
141 | if (profilePicHD != null) {
142 | profilePicHD = profilePicHD.replace(NOISE, "&")
143 | }
144 | if (profilePic != null) {
145 | profilePic = profilePic.replace(NOISE, "&")
146 | }
147 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(InstaPost(profilePicHD!!, InstaPost.INSTA_PROFILE, profilePic!!), null)) }
148 | return@launch
149 | }
150 | }
151 | }
152 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, IllegalArgumentException("No data resource found"))) }
153 |
154 | } catch (e: IOException) {
155 | withContext(Dispatchers.Main) { response.onResponse(InstaTask(null, e)) }
156 | }
157 | }
158 | }
159 |
160 | private fun matchPattern(data: String, patTxt: String): String? {
161 | val pattern = Pattern.compile(patTxt)
162 | val matcher = pattern.matcher(data)
163 | val patMatch = matcher.find()
164 | return if (!patMatch) {
165 | null
166 | } else matcher.group(1)
167 | }
168 |
169 | companion object {
170 | private val TAG = InstaDownloader::class.simpleName
171 | private const val DP_URL = "^(https://(www\\.)?instagram\\.com/[0-9a-zA-Z_.]+)"
172 | private const val NOISE = "\\u0026"
173 | private const val PROFILE_HD_PATTERN = "\"profile_pic_url_hd\":\"([^\"]*)\""
174 | private const val PROFILE_PATTERN = "\"profile_pic_url\":\"([^\"]*)\""
175 | }
176 | }
--------------------------------------------------------------------------------