{"id":14979756,"url":"https://github.com/prof18/youtubeparser","last_synced_at":"2025-10-28T19:32:06.723Z","repository":{"id":41384165,"uuid":"61236733","full_name":"prof18/YoutubeParser","owner":"prof18","description":"An Android library to get video's information from Youtube channels.","archived":false,"fork":false,"pushed_at":"2021-11-14T20:54:06.000Z","size":11038,"stargazers_count":89,"open_issues_count":1,"forks_count":30,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-09-29T03:22:26.588Z","etag":null,"topics":["android","android-library","statistics","video","youtube","youtube-api","youtube-channel"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prof18.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://www.paypal.me/MarcoGomiero"}},"created_at":"2016-06-15T19:55:45.000Z","updated_at":"2024-07-18T14:16:46.000Z","dependencies_parsed_at":"2022-09-22T08:41:14.606Z","dependency_job_id":null,"html_url":"https://github.com/prof18/YoutubeParser","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prof18%2FYoutubeParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prof18%2FYoutubeParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prof18%2FYoutubeParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prof18%2FYoutubeParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prof18","download_url":"https://codeload.github.com/prof18/YoutubeParser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219858899,"owners_count":16556039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","statistics","video","youtube","youtube-api","youtube-channel"],"created_at":"2024-09-24T14:00:35.945Z","updated_at":"2025-10-28T19:32:01.061Z","avatar_url":"https://github.com/prof18.png","language":"Kotlin","funding_links":["https://www.paypal.me/MarcoGomiero"],"categories":[],"sub_categories":[],"readme":"# YoutubeParser\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.prof18.youtubeparser/youtubeparser/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/com.prof18.youtubeparser/youtubeparser)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)\n\nThis is an Android library to get information of videos from Youtube channels. You can retrieve title, link and thumbnail of a video from a specific channel. You can also get the statistics of a video like view, like, dislike, favorite and comment count. Now it is also possible to load more videos by making a new request.\n\n## ⚠️ Important Notice\n\nThe library artifacts have been moved to MavenCentral. The group id is changed from `com.prof.youtubeparser` to `com.prof18.youtubeparser`.\nBe sure to add the gradle dependency to your root `build.gradle` file.\n```\nallprojects {\n    repositories {\n        mavenCentral()\n    }\n}\n```\n\n## How to\n### Import:\nThe library is uploaded on MavenCentral, so you can easily add the dependency:\n```Gradle\ndependencies {\n  compile 'com.prof18.youtubeparser:youtubeparser:\u003clatest-version\u003e'\n}\n```\n### Usage:\n\nStarting from the version 3.x, the library has been completely rewritten using Kotlin and the coroutines. However, The compatibility with Java has been maintained and the same code of the versions 2.x (and below) can be used.  \n\nIf you are using Kotlin you need to [launch](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html) the coroutine that retrieves the videos. \n\n\n#### To load videos from a specific channel:\n\n```kotlin\nimport com.prof.youtubeparser.Parser\nimport com.prof.youtubeparser.models.videos.Video\n\ncoroutineScope.launch(Dispatchers.Main) {\n    \n    val parser = Parser()\n    \n    //(CHANNEL_ID, NUMBER_OF_RESULT_TO_SHOW, ORDER_TYPE ,BROSWER_API_KEY)\n    //https://www.youtube.com/channel/UCVHFbqXqoYvEWM1Ddxl0QDg --\u003e channel id = UCVHFbqXqoYvEWM1Ddxl0QDg\n    //The maximum number of result to show is 50\n    //ORDER_TYPE --\u003e by date: \"Parser.ORDER_DATE\" or by number of views: \"ORDER_VIEW_COUNT\"  \n    val requestUrl = parser.generateRequest(\n            channelID = channelID,\n            maxResult = 20,\n            orderType = Parser.ORDER_DATE,\n            key = BuildConfig.KEY\n    )\n    try {\n        val result = parser.getVideos(requestUrl)\n        nextToken = result.nextToken\n        videoList = result.videos\n    } catch (e: Exception) {\n        // handle the exception\n    }\n}\n```\n\nIf you are still using Java, the code is very similar to the older versions of the library:\n\n```java\nimport com.prof.youtubeparser.Parser;\nimport com.prof.youtubeparser.models.videos.Video;\n\nParser mParser = new Parser();\nmParser.onFinish(new Parser.OnTaskCompleted() {\n    @Override\n    public void onTaskCompleted(@NonNull List\u003cVideo\u003e list, @NonNull String nextPageToken) {\n        // The list contains all the videos. For example you can use it for your adapter.\n        // The next page token can be used to retrieve more videos\n    }\n\n    @Override\n    public void onError(@NonNull Exception e) {\n        // handle the exception\n    }\n});\n\n//(CHANNEL_ID, NUMBER_OF_RESULT_TO_SHOW, ORDER_TYPE ,BROSWER_API_KEY)\n//https://www.youtube.com/channel/UCVHFbqXqoYvEWM1Ddxl0QDg --\u003e channel id = UCVHFbqXqoYvEWM1Ddxl0QDg\n//The maximum number of result to show is 50\n//ORDER_TYPE --\u003e by date: \"Parser.ORDER_DATE\" or by number of views: \"ORDER_VIEW_COUNT\"  \nString requestUrl = mParser.generateRequest(\n            CHANNEL_ID,\n            20,\n            Parser.ORDER_DATE,\n            BuildConfig.KEY\n    );\n\nmParser.execute(requestUrl);\n\n```\n\n##### Version 2.2 and belows:\n\n```java\nimport com.prof.youtubeparser.Parser;\nimport com.prof.youtubeparser.models.videos.Video;\n\nParser parser = new Parser();\n\n//(CHANNEL_ID, NUMBER_OF_RESULT_TO_SHOW, ORDER_TYPE ,BROSWER_API_KEY)\n//https://www.youtube.com/channel/UCVHFbqXqoYvEWM1Ddxl0QDg --\u003e channel id = UCVHFbqXqoYvEWM1Ddxl0QDg\n//The maximum number of result to show is 50\n//ORDER_TYPE --\u003e by date: \"Parser.ORDER_DATE\" or by number of views: \"ORDER_VIEW_COUNT\"  \nString url = parser.generateRequest(CHANNEL_ID, 20, Parser.ORDER_DATE, API_KEY);\nparser.execute(url);\nparser.onFinish(new Parser.OnTaskCompleted() {\n\n    @Override\n    public void onTaskCompleted(ArrayList\u003cVideo\u003e list, String nextPageToken) {\n      //what to do when the parsing is done\n      //the ArrayList contains all video data. For example you can use it for your adapter\n    }\n\n    @Override\n    public void onError() {\n        //what to do in case of error\n    }\n});\n```\nTo create a BROSWER API KEY you can follow\n\u003ca href=\"https://support.google.com/cloud/answer/6158862?hl=en#creating-browser-api-keys\"\u003e this guide.\u003c/a\u003e\n\n#### To load more videos from the same channel:\n\nTo load more videos, you can use the same method described above but with the following URL: \n\n```kotlin\nval requestUrl = parser.generateMoreDataRequest(\n                    channelID = channelID,\n                    maxResult = 20,\n                    orderType = Parser.ORDER_DATE,\n                    key = BuildConfig.KEY,\n                    nextToken = pageToken\n            )\n```\n\n    \n```Java\nString requestUrl = mParser.generateMoreDataRequest(\n                CHANNEL_ID,\n                20,\n                Parser.ORDER_DATE,\n                BuildConfig.KEY,\n                mNextToken\n        );\n```\nRemember that this request can be made only AFTER the a previous one, because you need the nextPageToken. Remember also that every request can get a maximum of 50 elements.\n\n#### To get the statistics of a video:\n\nIf you are using Kotlin you need to [launch](https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html) the coroutine that retrieves the videos. \n\n\n```kotlin\nimport com.prof.youtubeparser.VideoStats\nimport com.prof.youtubeparser.models.videos.Video\n\nval videoStats = VideoStats()\nval requestUrl = videoStats.generateStatsRequest(\n        videoID = videoId,\n        key = BuildConfig.KEY\n)\ncoroutineScope.launch(Dispatchers.Main) {\n    try {\n        _stats.postValue(videoStats.getStats(requestUrl))\n    } catch (e: Exception) {\n        e.printStackTrace()\n        _snackbar.value = \"An error has occurred. Please retry\"\n    }\n}\n```\n\nIf you are still using Java, the code is very similar to the older versions of the library:\n\n```java\nimport com.prof.youtubeparser.VideoStats;\nimport com.prof.youtubeparser.models.stats.Statistics;\n\nVideoStats videoStats = new VideoStats();\nvideoStats.onFinish(new VideoStats.OnTaskCompleted() {\n    @Override\n    public void onTaskCompleted(@NonNull Statistics stats) {\n        //Here you can set the statistic to a Text View for instance\n        \n        //for example:\n        String body = \"Views: \" + stats.getViewCount() + \"\\n\" +\n                    \"Like: \" + stats.getLikeCount() + \"\\n\" +\n                    \"Dislike: \" + stats.getDislikeCount() + \"\\n\" +\n                    \"Number of comment: \" + stats.getCommentCount() + \"\\n\" +\n                    \"Number of favourite: \" + stats.getFavoriteCount();\n    }\n\n    @Override\n    public void onError(@NonNull Exception e) {\n        // handle the exception\n    }\n});\n\nString requestUrl = videoStats.generateStatsRequest(videoId, BuildConfig.KEY);\nvideoStats.execute(requestUrl);\n```\n\n##### Version 2.2 and belows:\n\n\n```Java\nimport com.prof.youtubeparser.VideoStats;\nimport com.prof.youtubeparser.models.stats.Statistics;\n\nVideoStats videoStats = new VideoStats();\nString url = videoStats.generateStatsRequest(videoId, API_KEY);\nvideoStats.execute(url);\nvideoStats.onFinish(new VideoStats.OnTaskCompleted() {\n  @Override\n  public void onTaskCompleted(Statistics stats) {\n      //Here you can set the statistic to a Text View for instance\n\n      //for example:\n      String body = \"Views: \" + stats.getViewCount() + \"\\n\" +\n                    \"Like: \" + stats.getLikeCount() + \"\\n\" +\n                    \"Dislike: \" + stats.getDislikeCount() + \"\\n\" +\n                    \"Number of comment: \" + stats.getCommentCount() + \"\\n\" +\n                    \"Number of favourite: \" + stats.getFavoriteCount();\n  }\n\n  @Override\n  public void onError() {\n      //what to do in case of error\n  }\n});\n```\n## Sample app\nI wrote a simple app that shows videos from Android Developer Youtube Channel.\n\n\u003cimg src=\"https://raw.githubusercontent.com/prof18/YoutubeParser/master/Screen.png\" width=\"30%\" height=\"30%\"\u003e\n\nThe sample is written both in Kotlin and Java. You can browse the Kotlin code [here](https://github.com/prof18/YoutubeParser/tree/master/samplekotlin) and the Java code [here](https://github.com/prof18/YoutubeParser/tree/master/samplejava)\n\nPlease use the issues tracker only to report issues. If you have any kind of question you can ask them on [the blog post](https://medium.com/@marcogomiero/new-big-update-for-youtube-parser-video-stats-and-much-more-79dde73f21e6)\n\n## Changelog\nFrom version 1.4.4 and above, the changelog is available in the [release section.](https://github.com/prof18/YoutubeParser/releases)\n\n- 21 May 2019 - Rewrote library with Kotlin - Version 3.0.0\n- 14 December 2017 - Improved Error Management - Version 2.2\n- 12 August 2017 - Fixed Library Manifest - Version 2.1\n- 22 June 2017 - Big update: now you can load more video and get the statistic of a video - Version 2.0\n- 17 June 2016 - Fixed a bug on Locale - Version 1.1\n- 15 June 2016 - First release  - Version 1.0\n\n## License\n```\n   Copyright 2016 Marco Gomiero\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n## Apps using RSS Parser\nIf you are using Youtube Parser in your app and would like to be listed here, please open a pull request!\n\n\u003cdetails\u003e\n  \u003csummary\u003eList of Apps using Youtube Parser\u003c/summary\u003e\n\n* [Your App Name](www.yourapplink.com)\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprof18%2Fyoutubeparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprof18%2Fyoutubeparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprof18%2Fyoutubeparser/lists"}