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

Zap2it.com #2679

Merged
merged 11 commits into from
Feb 14, 2025
Merged

Zap2it.com #2679

merged 11 commits into from
Feb 14, 2025

Conversation

Newbiect
Copy link
Contributor

@Newbiect Newbiect commented Feb 8, 2025

No description provided.

@dtngfan85
Copy link

Some notes:

On Zap2it Antenna lineups have a blank "device" value so you need to remove the "!device" check so people can use it to get listings as many cities have antenna only subchannels that are not carried by any cable or sat provider:

      const [device, lineupId, headendId, countryCode, postalCode, prgsvcid] = channel.site_id.split('/')

      if (!lineupId || !headendId || !countryCode || !postalCode || !prgsvcid) {
        throw new Error('El site_id no contiene todos los valores obligatorios.')
      }

i.e. for WRNNDT3 in NYC zip code 10036, this would be the required "site_id" value:
/USA-lineupId-DEFAULT/lineupId/USA/10036/55567
And this would be the resulting POST data:
lineupId=USA-lineupId-DEFAULT&IsSSLinkNavigation=true&timespan=336&timestamp=1739055600&prgsvcid=55567&headendId=lineupId&countryCode=USA&postalCode=10036&device=&userId=-&aid=gapzap&DSTUTCOffset=-240&STDUTCOffset=-300&DSTStart=2025-03-09T02%3A00Z&DSTEnd=2025-11-02T02%3A00Z&languagecode=en-us

If you want to be able to download more than 2 days, you also need to make sure the timestamp parameter doesn't change based on the date you request. The API request fails if the timestamp is more than 1 day into the future, so a quick workaround to get the full 14 days was to remove the "date" from the const timestamp line so it would always use the current time:
const timestamp = dayjs().unix().toString()
But to future proof it you might might want to do some advanced coding to match the behavior on zap2it.com where the timestamp value is always 24 hours prior to current time rounded to the previous half hour mark. i.e. if it's 6:12pm ET on 2/9, you would use 1739055600 which is 6:00pm ET on 2/8

epg-grabber v0.38.0 now sends "EPGGrabber" as the default User-Agent, which zap2it blocks, so you need to supply a browser based User-Agent in the headers.

@Newbiect
Copy link
Contributor Author

I corrected this part const [device, lineupId, headendId, countryCode, postalCode, prgsvcid] = channel.site_id.split('/')

  if (!lineupId || !headendId || !countryCode || !postalCode || !prgsvcid) {
    throw new Error('El site_id no contiene todos los valores obligatorios.')
  }

i added the user-agent...

And the last part, the code works with the information of the 14 days but it is limited with this part return programs.filter(p => dayjs(p.start).add(dayjs(p.start).utcOffset(), 'minute').isBetween(date.startOf('day').utc(), date.endOf('day').utc(), 'second', '[]')) because it is too much information. And if it works with previous days or not I really don't know, what I know is that as it is currently it gets the information for the correct day.

@PopeyeTheSai10r
Copy link
Collaborator

Fixes #2372

npm test --- zap2it.com

> test
> run-script-os zap2it.com


> test:win32
> SET "TZ=Pacific/Nauru" && npx jest --runInBand zap2it.com

 PASS  sites/zap2it.com/zap2it.com.test.js (8.375 s)
   can generate valid url (12 ms)
   can parse response (17 ms)
   can handle empty guide (3 ms)

Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        9.146 s
Ran all test suites matching /zap2it.com/i.
npm run grab --- --site=zap2it.com

> grab
> npx tsx scripts/commands/epg/grab.ts --site=zap2it.com

starting...
config:
  output: guide.xml
  maxConnections: 1
  gzip: false
  site: zap2it.com
loading channels...
  found 595 channel(s)
run #1:
  [1/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/91035 - Feb 10, 2025 (8 programs)
  [2/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/91035 - Feb 11, 2025 (8 programs)
  [3/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/114483 - Feb 11, 2025 (9 programs)
  [4/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/60222 - Feb 11, 2025 (19 programs)
  [5/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/60222 - Feb 10, 2025 (19 programs)
  [6/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/114483 - Feb 10, 2025 (8 programs)
  [7/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/62077 - Feb 11, 2025 (24 programs)
  [8/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/62077 - Feb 10, 2025 (24 programs)
  [9/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/11069 - Feb 11, 2025 (19 programs)
  [10/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/11069 - Feb 10, 2025 (19 programs)
  [11/1190] zap2it.com (es) - X/USA-DITV-DEFAULT/DITV/USA/12084/16604 - Feb 11, 2025 (10 programs)
  ...

@BellezaEmporium BellezaEmporium merged commit 0b9276c into iptv-org:master Feb 14, 2025
1 check passed
@PopeyeTheSai10r PopeyeTheSai10r mentioned this pull request Feb 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants