Changeset 2310925
- Timestamp:
- 05/23/2020 10:22:01 PM (6 years ago)
- Location:
- wsm-downloader/trunk
- Files:
-
- 3 edited
-
dl_engine/instagram/decoder.php (modified) (4 diffs)
-
readme.txt (modified) (3 diffs)
-
wsm_downloader.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wsm-downloader/trunk/dl_engine/instagram/decoder.php
r2217953 r2310925 1 1 <?php 2 3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly4 5 2 class instagram { 6 3 function decoder($url) { 7 4 $msg['success'] = false; 8 5 $msg['body'] = 'Seems like there is nothing here!'; 9 $data = wsmd_file_get_content($url); 10 libxml_use_internal_errors(true); 11 $doc = new DomDocument(); 12 $doc->loadHTML($data); 13 $xpath = new DOMXPath($doc); 14 $query = '//*/meta[starts-with(@property, \'og:\')]'; 15 $metas = $xpath->query($query); 16 foreach ($metas as $meta) { 6 7 $fixed_url = explode('?' , $url); 8 $url = rtrim($fixed_url[0] , '/'); 9 10 $data0 = json_decode(wsmd_file_get_content('https://api.instagram.com/oembed/?url='.$url)); 11 12 if(isset($data0->title)){ 13 $msg['title'] = $data0->title; 14 $msg['thumnail_src'] = $data0->thumbnail_url; 17 15 $msg['success'] = true; 18 unset($msg['body']); 19 $property = $meta->getAttribute('property'); 20 $content = $meta->getAttribute('content'); 21 if ($property == 'og:title') { 22 $msg['title'] = explode("Instagram:" , $content)[1]; 23 } 24 if ($property == 'og:image') { 25 $msg['thumnail_src'] = $content; 26 } 27 if ($property == 'og:video:secure_url') { 28 $src = $content; 16 $src = $data0->thumbnail_url; 17 $quality = $data0->thumbnail_width . 'x' . $data0->thumbnail_height; 18 $type_p = pathinfo(explode("?" , $src)[0], PATHINFO_EXTENSION); 19 $msg['photo'][] = ['direct_url' => $src, 'feu_url' => $src, 'type' => $type_p, 'quality' => $quality, 'size' => wsmd_get_file_size($src), ]; 20 } 21 22 $data = wsmd_file_get_content($url.'/embed/captioned/'); 23 24 ////////aditional info extractor 25 $json_file = $this->get_string_between($data, "window.__additionalDataLoaded('graphql',", ');'); 26 $parsed_json = json_decode($json_file); 27 $post_page[0] = $parsed_json; 28 29 30 31 32 if(isset($post_page[0]->shortcode_media->display_url)){ 33 unset($msg['photo']); 34 $msg['thumnail_src'] = $post_page[0]->shortcode_media->display_url; 35 $msg['success'] = true; 36 $src = $post_page[0]->shortcode_media->display_url; 37 $quality = $data0->thumbnail_width . 'x' . $data0->thumbnail_height; 38 $type_p = pathinfo(explode("?" , $src)[0], PATHINFO_EXTENSION); 39 $msg['photo'][] = ['direct_url' => $src, 'feu_url' => $src, 'type' => $type_p, 'quality' => $quality, 'size' => wsmd_get_file_size($src), ]; 40 } 41 42 43 if(isset($post_page[0]->shortcode_media->video_url)){ 44 $src = $post_page[0]->shortcode_media->video_url; 29 45 $type = pathinfo(explode("?" , $src)[0], PATHINFO_EXTENSION); 30 46 $msg['streams'][] = ['direct_url' => $src, 'feu_url' => $src, 'type' => $type, 'quality' => 'HQ', 'size' => wsmd_get_file_size($src), ]; 31 } 32 } 33 ////////aditional info extractor 34 $json_file = $this->get_string_between($data, 'window._sharedData = {', '};'); 35 $parsed_json = json_decode("{" . $json_file . "}"); 36 $post_page = $parsed_json->entry_data->PostPage; 37 if (!empty($post_page[0]->graphql->shortcode_media->edge_sidecar_to_children)) { 38 $childrens = $post_page[0]->graphql->shortcode_media->edge_sidecar_to_children->edges; 47 } 48 49 50 if (!empty($post_page[0]->shortcode_media->edge_sidecar_to_children)) { 51 $childrens = $post_page[0]->shortcode_media->edge_sidecar_to_children->edges; 39 52 foreach ($childrens as $child) { 40 53 $child_node = $child->node; … … 53 66 54 67 55 if(empty($msg['photo']) and !empty($post_page[0]-> graphql->shortcode_media->display_resources)){56 $resurces = $post_page[0]-> graphql->shortcode_media->display_resources;68 if(empty($msg['photo']) and !empty($post_page[0]->shortcode_media->display_resources)){ 69 $resurces = $post_page[0]->shortcode_media->display_resources; 57 70 foreach($resurces as $resurce){ 58 71 $src = $resurce->src; … … 62 75 } 63 76 } 77 78 if(empty($msg['photo'][1]) and strpos($data , 'srcset') !== false){ 79 $first_extract = $this->get_string_between(str_replace('&' , '&' , $data) , '<img class="EmbeddedMediaImage"' , '/>'); 80 $second = $this->get_string_between($first_extract , 'srcset="' , '"'); 81 $exloded = explode("," , $second); 82 foreach($exloded as $explod1){ 83 $extract = explode(' ' , $explod1); 84 $msg['photo'][] = ['direct_url' => $extract[0], 'feu_url' => $extract[0], 'type' => 'jpg' , 'quality' => $extract[1], 'size' => wsmd_get_file_size($extract[0]), ]; 85 } 86 87 } 64 88 65 89 return json_encode($msg); 66 90 } 67 68 91 69 92 function get_string_between($string, $start, $end) { … … 74 97 $len = strpos($string, $end, $ini) - $ini; 75 98 return substr($string, $ini, $len); 76 } 99 } 100 101 77 102 } -
wsm-downloader/trunk/readme.txt
r2218078 r2310925 4 4 Donate link: https://ttmga.com 5 5 Requires at least: 4.9 6 Tested up to: 5. 3.26 Tested up to: 5.4.1 7 7 Requires PHP: 7.0 8 8 Stable tag: trunk … … 146 146 Released into the wordpress 147 147 148 =1.1.0= 149 Instagram downloader issue has been solved 150 148 151 149 152 … … 151 154 152 155 =1.0.0= 156 Just released into the WordPress 153 157 154 Just released into the WordPress 158 =1.0.0= 159 Instagram downloader issue has been solved -
wsm-downloader/trunk/wsm_downloader.php
r2217953 r2310925 5 5 * Author: S.J.Hossseini 6 6 * Author URI: https://t.me/ttmga 7 * Version: 1. 0.07 * Version: 1.1.0 8 8 * Text Domain: wsm-downloader 9 9 * Domain Path: /languages … … 16 16 define('WSMD_PLUGIN_FILE', plugin_dir_path(__FILE__)); 17 17 define('WSMD_PLUGIN_URL', plugins_url('', __FILE__)); 18 define('WSMD_SCRIPT_VERSION', '1. 0.1');18 define('WSMD_SCRIPT_VERSION', '1.1.1'); 19 19 } 20 20 … … 171 171 $defaults["shortcode"]["form"]["button"]["border-style"] = "solid" ; 172 172 $defaults["shortcode"]["form"]["button"]["border-radius"] = "0" ; 173 $defaults["shortcode"]["preloader"] = WSMD_PLUGIN_URL.'/assets/img/preloader.gif' ;173 $defaults["shortcode"]["preloader"] = str_replace('_' , '-' , WSMD_PLUGIN_URL).'/assets/img/preloader.gif' ; 174 174 $defaults["shortcode"]["modal"]["active"] = "on" ; 175 175 $defaults["shortcode"]["modal"]["ads1"] = "" ;
Note: See TracChangeset
for help on using the changeset viewer.