1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace Vioscope;
- if ( ! class_exists( '\Vioscope\Trending' ) ) :
- class Trending {
- // YT video id
- private $data;
- // Processed data
- public $info;
- public $page; // TODO: implement.
- public $region = 'US';
- public $total_page; // TODO: implement.
- function __construct( $fetch = false ) {
- if ( $fetch == true ) {
- $this->region = 'US';
- return $this->fetch_data( null, 1 );
- }
- }
- public function fetch_data( $region = null, $page = null ) {
- if ( ! $region ) {
- $region = $this->region;
- } else {
- $this->region = $region;
- }
- if ( ! $page ) {
- $page = $this->page;
- } else {
- $this->page = $page;
- }
- $html = get_url_contents( "https://www.youtube.com/feed/trending?gl={$this->region}&hl=en" );
- $this->data = get_initial_data( $html );
- return extract_items( $this->data );
- }
-
- }
- endif;
|