php-snapchat icon indicating copy to clipboard operation
php-snapchat copied to clipboard

Download video with overlay

Open eberth opened this issue 10 years ago • 12 comments

When I try to download a snap that contains a video and a drawing/text, only the drawing/text layer is downloaded as a video... how can I download both with one request?

eberth avatar Jul 23 '14 02:07 eberth

When the video has an overlay, the returned object is an array consisting of 'filename'->'data content' key-value pair Of length 2. One is overlay the other is video.

I'm not on my PC and don't remember exactly which.

You'd want to check if the return is an array, if so then foreach the array writing the data to a different file.

Sent from my iPhone

On Jul 22, 2014, at 22:05, Eberth Manjarrez [email protected] wrote:

When I try to download a snap that contains a video and a drawing/text, only the drawing/text layer is downloaded as a video... how can I download both with one request?

— Reply to this email directly or view it on GitHub.

hisham-albeik avatar Jul 23 '14 02:07 hisham-albeik

Just to add;

  • array(
  • overlay~zip-CE6F660A-4A9F-4BD6-8183-245C9C75B8A0 => overlay_file_data,
  • media~zip-CE6F660A-4A9F-4BD6-8183-245C9C75B8A0 => m4v_file_data
  • )

Sent from my iPhone

On Jul 22, 2014, at 22:05, Eberth Manjarrez [email protected] wrote:

When I try to download a snap that contains a video and a drawing/text, only the drawing/text layer is downloaded as a video... how can I download both with one request?

— Reply to this email directly or view it on GitHub.

hisham-albeik avatar Jul 23 '14 02:07 hisham-albeik

Am I doing something wrong? Not working, its creating empty files...

if(!is_array($data)) { //if not an array, then just save the video.. $data = $snapchat->getMedia($id); $filename = 'media/'. $sender . '-snap-video-' . $sent . '.mp4'; file_put_contents($filename, $data); } else { //overlay $filename = 'media/'. $sender . '-snap-overlay-' . $sent . '.png'; file_put_contents($filename, $data[0]);

//video file $filename = 'media/'. $sender . '-snap-video-' . $sent . '.mp4'; file_put_contents($filename, $data[1]); }

eberth avatar Jul 23 '14 03:07 eberth

The array is a key value pair. There is no '0'. If you want you can use: $keys = array_keys($data); $overlay_key = $keys[0]; $media_key = $keys[1];

$overlaydata = $data[$overlay_key]; $mediadata = $data[$media_key];

Sent from my iPhone

On Jul 22, 2014, at 23:50, Eberth Manjarrez [email protected] wrote:

Am I doing something wrong? Not working, its creating empty files...

if(!is_array($data)) { //if not an array, then just save the video.. $data = $snapchat->getMedia($id); $filename = 'media/'. $sender . '-snap-video-' . $sent . '.mp4'; file_put_contents($filename, $data); } else { //overlay $filename = 'media/'. $sender . '-snap-overlay-' . $sent . '.png'; file_put_contents($filename, $data[0]);

//video file $filename = 'media/'. $sender . '-snap-video-' . $sent . '.mp4'; file_put_contents($filename, $data[1]); }

— Reply to this email directly or view it on GitHub.

hisham-albeik avatar Jul 23 '14 04:07 hisham-albeik

thanks, that worked perfectly!

eberth avatar Jul 23 '14 04:07 eberth

Hi, me again... it worked for snaps, but for stories I think there's something missing, I guess the whole zip to array code you wrote for the snaps has yet to be implemented for stories, or does it work differently?

eberth avatar Jul 23 '14 05:07 eberth

I've actually never tested it on stories. I didnt realize stories uses a different method to get the media; so it doesn't test if it was zipped or not. I'll look into adding it. At the moment what you could do is check if the first two bytes are x50 x4B (hex), then perform the unzip operation.

hishamalbeik avatar Jul 23 '14 16:07 hishamalbeik

Hi, is it possible to upload videos with an overlay? As in, let's say I downloaded the video and overlay from someone, can I "forward" that in the same way it came?

fefogarcia avatar Nov 03 '14 00:11 fefogarcia

Never mind, I figured it out :) All I had to do was deactivate the unCompress method and use it manually when necessary. Thanks!!

fefogarcia avatar Nov 03 '14 02:11 fefogarcia

Yup. Maybe it should be an option, defaulted to unCompress that can be overridden.

On Sun, Nov 2, 2014 at 9:03 PM, felipeedoardo [email protected] wrote:

Never mind, I figured it out :) All I had to do was deactivate the unCompress method and use it manually when necessary. Thanks!!

— Reply to this email directly or view it on GitHub https://github.com/JorgenPhi/php-snapchat/issues/39#issuecomment-61434290 .

hisham-albeik avatar Nov 03 '14 02:11 hisham-albeik

True. Unfortunately, even though the ZIP stays intact, Snapchat doesn't seem to accept it as an upload. I went really deep into the code and just can't figure out the reason, since the data that I'm sending to be encrypted and uploaded is exactly the same data that I had just received from the API.

So I'm trying to figure out why that is.

fefogarcia avatar Nov 03 '14 03:11 fefogarcia

I am able to upload the zipped file and get a media id back, however if I use that mediaID to send the snap it will not send and throw a 415 Http error.

PS: Any luck with this? Someone?

gurinderhans avatar Jan 20 '15 03:01 gurinderhans