Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yes.co.il Need help fixing the config.js #2497

Open
fraudiay79 opened this issue Dec 9, 2024 · 5 comments
Open

yes.co.il Need help fixing the config.js #2497

fraudiay79 opened this issue Dec 9, 2024 · 5 comments
Labels
site:geoblocked EPG website is geo-blocked source request Request to add a new source

Comments

@fraudiay79
Copy link

fraudiay79 commented Dec 9, 2024

Source

https://www.yes.co.il/content/tvguide

Notes

I need assistance fixing this config.js for yes.co.il. I've tried multiple iterations at this point and cannot get this to run: @tohenk @freearhey @davidclaeysquinones

const axios = require('axios');
const dayjs = require('dayjs');
const utc = require('dayjs/plugin/utc');
const timezone = require('dayjs/plugin/timezone');
const customParseFormat = require('dayjs/plugin/customParseFormat');

dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.extend(customParseFormat);

module.exports = {
  site: 'yes.co.il',
  days: 3,
  request: {
    cache: {
      ttl: 60 * 60 * 1000 // 1 hour
    }
  },
  url({ channel, date }) {
    return `https://www.yes.co.il/o/yes/servletlinearsched/getscheduale?startdate=${date.format('YYYYMMDD')}&p_auth=${channel.p_auth}`;
  },
  async parser({ content }) {
    const shows = [];
    const data = JSON.parse(content);

    data.forEach(program => {
      const show = {
        channel: program.channelID,
        title: program.scheduleItemName,
        description: program.scheduleItemSynopsis || 'No description available',
        startTime: dayjs(program.startDate).utc().format(),
        endTime: dayjs(program.startDate).add(dayjs.duration(program.broadcastItemDuration)).utc().format()
      };
      shows.push(show);
    });

    return shows;
  },
  async channels() {
    const authToken = await this.getAuthToken();
    const url = `https://www.yes.co.il/o/yes/servletlinearsched/getchannels?p_auth=${authToken}`;
    
    try {
      const response = await axios.get(url);
      const channels = response.data.map(channel => ({
        lang: 'he',
        name: channel.channelID,
        site_id: channel.channelID,
        p_auth: authToken
      }));
      return channels;
    } catch (error) {
      console.error('Error fetching channels:', error);
      return [];
    }
  },
  async getAuthToken() {
    const url = 'https://www.yes.co.il/content/tvguide';
    const response = await axios.get(url);
    const textToSearch = ';Liferay.authToken=';
    const mainPageHtml = response.data;
    const idx = mainPageHtml.indexOf(textToSearch);
    const val = mainPageHtml.substring(idx + textToSearch.length + 1, 30);
    const authToken = val.split(';')[0].substring(0, val.length - 1);
    return authToken;
  }
};
@fraudiay79 fraudiay79 added the source request Request to add a new source label Dec 9, 2024
@freearhey
Copy link
Collaborator

It shows me that the site is currently under renovation:
image translated
https://www.yes.co.il/

@fraudiay79
Copy link
Author

The guide link is up: https://www.yes.co.il/content/tvguide

@davidclaeysquinones
Copy link
Contributor

I've taken a look at it. First of all the site seems under construction or either it's being geolocked.

The method you made to get an auth token seems weird. I would expect some POST endpoint in order to get an auth token.
Again I'm not able to verify it since I can't access the page, but it's what my gut feeling tells me.

If the site is being geolocked you could share the requests the site performs. That way we can maybe suggest some changes.

@fraudiay79
Copy link
Author

I guess it's not geoblocked in the US. Let me know if need the har or some other file.

@davidclaeysquinones
Copy link
Contributor

I've managed to get the page through an US VPN.

This is how your method for your auth token should look like:

async getAuthToken() {
   const url = 'https://www.yes.co.il/content/tvguide';
   const response = await axios.get(url);
   const textToSearch = ';Liferay.authToken="';
   const mainPageHtml = response.data;
   const beginIndex = mainPageHtml.indexOf(textToSearch);
   const endIndex = mainPageHtml.indexOf('";', beginIndex + 1);
   const authToken = mainPageHtml.substring(beginIndex + textToSearch.length + 1, endIndex);
   return authToken;
 }

With this change it still won't work.
I've tried this :

const response = await axios.get(url, {
       headers: {
           'Content-Type':'application/json',
           'Referer': 'https://www.yes.co.il/content/tvguide',
           'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71',
           'X-Requested-With': 'XMLHttpRequest',
           'Cookie': 'LFR_UID=0'
       }
     });

The issue is probably that we need to figure out a way to get the session cookie from the server.
I've not gotten around that currently.

@freearhey freearhey added the site:geoblocked EPG website is geo-blocked label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site:geoblocked EPG website is geo-blocked source request Request to add a new source
Development

No branches or pull requests

3 participants