hulu.sh

Topics regarding RTMPDump.
kitana
Posts: 24
Joined: Sat Mar 23, 2013 3:50 am

Re: hulu.sh

Postby kitana » Wed Mar 27, 2013 6:39 am

svnpenn wrote:Add MP4 support

If FFmpeg is found at /usr/local/bin, then remux to MP4 from FLV

github.com/svnpenn/a/commit/18e0


Is it possible to do this (auto?) remux with the previous hulu-xp.sh you were working on? I had to manually run the below command on every FLV

Code: Select all

ffmpeg -i file.flv -vcodec copy -acodec copy file.mp4

svnpenn
Posts: 263
Joined: Tue Nov 01, 2011 12:19 am

Re: hulu.sh

Postby svnpenn » Wed Mar 27, 2013 6:43 am

kitana wrote:Is it possible to do this (auto?) remux with the previous hulu-xp.sh you were working on? I had to manually run the below command on every FLV

Code: Select all

ffmpeg -i file.flv -vcodec copy -acodec copy file.mp4


Yes, with hulu-xp.sh I only changed the "coredump" function nothing more.

kitana
Posts: 24
Joined: Sat Mar 23, 2013 3:50 am

Re: hulu.sh

Postby kitana » Wed Mar 27, 2013 7:07 am

svnpenn wrote:Script now has preliminary support for episode titles.
github.com/svnpenn/a/commit/63ab

It will save in this format
Frasier 6x1 Good Grief.flv

However you will need "jq" in your /usr/local/bin
stedolan.github.com/jq

If you do not have "jq" it will be saved in this format
441362.flv


I would assume hulu-xp.sh also includes support for episodic titles?

svnpenn
Posts: 263
Joined: Tue Nov 01, 2011 12:19 am

Re: hulu.sh

Postby svnpenn » Wed Mar 27, 2013 7:20 am

kitana wrote:I would assume hulu-xp.sh also includes support for episodic titles?


Yes.

kitana
Posts: 24
Joined: Sat Mar 23, 2013 3:50 am

Re: hulu.sh

Postby kitana » Wed Mar 27, 2013 7:36 am

svnpenn wrote:
kitana wrote:I would assume hulu-xp.sh also includes support for episode titles?


Yes.

Wouldn't have been possible without cygwin-25 (tried cygwin-19 earlier to no avail)

Hulu.jpg

svnpenn
Posts: 263
Joined: Tue Nov 01, 2011 12:19 am

Re: hulu.sh

Postby svnpenn » Wed Mar 27, 2013 7:59 am

kitana wrote:Wouldn't have been possible without cygwin-25 (tried cygwin-19 earlier to no avail)


Ah yes, "sed" was missing until today. I never planned to use Baby Cygwin with these scripts, but I am glad it works.

Terminator02
Posts: 11
Joined: Thu Mar 28, 2013 1:38 am

Re: hulu.sh

Postby Terminator02 » Thu Mar 28, 2013 1:51 am

I'm getting this when I try to run the script:
Image

Since I didn't see a download from hulu.sh, I just copied all of it into a new file and named it hulu.sh, here is what's in it:

Code: Select all

#!/bin/bash

if [[ $OSTYPE =~ linux ]]
then
  FIREFOX=firefox
else
  FIREFOX="$PROGRAMFILES/mozilla firefox/firefox"
fi

warn ()
{
  printf '\e[36m%s\e[m\n' "$*"
}

log ()
{
  unset PS4
  set $((set -x; : "$@") 2>&1)
  shift
  warn $*
  eval $*
}

usage ()
{
  echo "usage: $0 [CDN FILETYPE] URL"
  echo
  echo "CDN       content delivery network"
  echo "FILETYPE  quality"
  echo
  echo "run with just URL to get CDN and FILETYPE params"
  exit
}

serialize_xml ()
{
  set "${!1/<}"
  eval set ${1/>}
  for oo
  do
    set ${oo/=/ }
    read ${1/[-:]} <<< $2
  done
}

coredump ()
{
  arg_pid=$!
  arg_prog=$1
  echo waiting for $arg_prog to load...
  aaa=80
  set 0 0
  while sleep 1
  do
    mapfile bbb </proc/$arg_pid/maps
    (( ccc = ${2} - ${1} ))
    (( ddd = ${#bbb[*]} - ${2} ))
    if (( ${ccc/-} + ${ddd/-} < aaa ))
    then
      break
    fi
    set ${2} ${#bbb[*]}
  done
  echo dumping $arg_prog...
  read WINPID </proc/$arg_pid/winpid
  dumper hulu $WINPID 2>&- &
  until [ -s hulu.core ]
  do
    sleep 1
  done
  kill -13 $arg_pid
}

download ()
{
  IFS=/ read gg hh <<< "$2"
  exec 3< /dev/tcp/$gg/80
  {
    echo GET /$hh HTTP/1.1
    echo connection: close
    echo host: $gg
    echo
  } >&3
  sed '1,/^$/d' <&3 > $1
}

[ $1 ] || usage
[ $3 ] || set '' '' $1
arg_cdn=$1
arg_filetype=$2
arg_url=$3
arg_pwd=$PWD
cd $WINDIR
echo ProtectedMode=0 > system32/macromed/flash/mms.cfg
rm -r /tmp
mkdir /tmp
cd "$APPDATA/mozilla/firefox"
read aa < <(find -name cookies.sqlite -exec ls -t {} +)
cp "$aa" /tmp
read aa < <(find -name prefs.js -exec ls -t {} +)
cp "$aa" /tmp
cd /tmp
MOZ_DISABLE_OOP_PLUGINS=1 "$FIREFOX" -no-remote -profile . $arg_url &
coredump firefox
grep -ao '<video [[:print:]]*>' hulu.core | sort | uniq -w123 > hulu.smil

if ! [ -s hulu.smil ]
then
  warn dumped too soon, retry
  echo $aaa $ccc $ddd
  exit
fi

while read video
do
  serialize_xml video
  if ! [ $arg_cdn ]
  then
    printf '%-9s  %9s\n' $cdn $filetype
  elif [ $cdn$filetype = $arg_cdn$arg_filetype ]
  then
    break
  else
    false
  fi
done < hulu.smil

[ $? = 0 ] || usage
[ $arg_cdn ] || exit
[[ $arg_url =~ [0-9]+ ]]

if [ -a /usr/local/bin/jq ]
then
  download hulu.json "www.hulu.com/api/2.0/video?id=$BASH_REMATCH"
  {
    read uu
    read vv
    read ww
    read xx
  } < <(jq -r '.show.name, .season_number, .episode_number, .title' hulu.json)
  flv="${uu} ${vv}x${ww} ${xx}"
else
  flv="$BASH_REMATCH"
fi

cd "$arg_pwd"
app="${server#*//*/}?${token//amp;}"

log rtmpdump \
  -W http://download.hulu.com/huludesktop.swf \
  -r $server \
  -a $app \
  -y $stream \
  -o "$flv.flv"

if [ -a /usr/local/bin/ffmpeg ]
then
  log ffmpeg -i "$flv.flv" -c copy -v warning "$flv.mp4"
  log rm "$flv.flv"
fi

svnpenn
Posts: 263
Joined: Tue Nov 01, 2011 12:19 am

Re: hulu.sh

Postby svnpenn » Thu Mar 28, 2013 3:10 am

Terminator02 wrote:I'm getting this when I try to run the script:
Since I didn't see a download from hulu.sh, I just copied all of it into a new file and named it hulu.sh, here is what's in it:


GitHub has been around for 5 years now, cmon

raw.github.com/svnpenn/a/master/hulu.sh

Terminator02
Posts: 11
Joined: Thu Mar 28, 2013 1:38 am

Re: hulu.sh

Postby Terminator02 » Thu Mar 28, 2013 10:30 am

svnpenn wrote:
Terminator02 wrote:I'm getting this when I try to run the script:
Since I didn't see a download from hulu.sh, I just copied all of it into a new file and named it hulu.sh, here is what's in it:


GitHub has been around for 5 years now, cmon

raw.github.com/svnpenn/a/master/hulu.sh

I opened that raw link before, it just opens up in my browser like so:
Image

Therefore, I tried saving the page as "hulu.sh" and got:

Code: Select all

<!-- saved from url=(0047)https://raw.github.com/svnpenn/a/master/hulu.sh -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script type="text/javascript" src="chrome-extension://bfbmjmiodbnnpllbbbfblcplfjjepjdn/js/injected.js"></script><style type="text/css"></style></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/bin/bash

if [[ $OSTYPE =~ linux ]]
then
  FIREFOX=firefox
else
  FIREFOX="$PROGRAMFILES/mozilla firefox/firefox"
fi

warn ()
{
  printf '\e[36m%s\e[m\n' "$*"
}

log ()
{
  unset PS4
  set $((set -x; : "$@") 2&gt;&amp;1)
  shift
  warn $*
  eval $*
}

usage ()
{
  echo "usage: $0 [CDN FILETYPE] URL"
  echo
  echo "CDN       content delivery network"
  echo "FILETYPE  quality"
  echo
  echo "run with just URL to get CDN and FILETYPE params"
  exit
}

serialize_xml ()
{
  set "${!1/&lt;}"
  eval set ${1/&gt;}
  for oo
  do
    set ${oo/=/ }
    read ${1/[-:]} &lt;&lt;&lt; $2
  done
}

coredump ()
{
  arg_pid=$!
  arg_prog=$1
  echo waiting for $arg_prog to load...
  aaa=80
  set 0 0
  while sleep 1
  do
    mapfile bbb &lt;/proc/$arg_pid/maps
    (( ccc = ${2} - ${1} ))
    (( ddd = ${#bbb[*]} - ${2} ))
    if (( ${ccc/-} + ${ddd/-} &lt; aaa ))
    then
      break
    fi
    set ${2} ${#bbb[*]}
  done
  echo dumping $arg_prog...
  read WINPID &lt;/proc/$arg_pid/winpid
  dumper hulu $WINPID 2&gt;&amp;- &amp;
  until [ -s hulu.core ]
  do
    sleep 1
  done
  kill -13 $arg_pid
}

download ()
{
  IFS=/ read gg hh &lt;&lt;&lt; "$2"
  exec 3&lt; /dev/tcp/$gg/80
  {
    echo GET /$hh HTTP/1.1
    echo connection: close
    echo host: $gg
    echo
  } &gt;&amp;3
  sed '1,/^$/d' &lt;&amp;3 &gt; $1
}

[ $1 ] || usage
[ $3 ] || set '' '' $1
arg_cdn=$1
arg_filetype=$2
arg_url=$3
arg_pwd=$PWD
cd $WINDIR
echo ProtectedMode=0 &gt; system32/macromed/flash/mms.cfg
rm -r /tmp
mkdir /tmp
cd "$APPDATA/mozilla/firefox"
read aa &lt; &lt;(find -name cookies.sqlite -exec ls -t {} +)
cp "$aa" /tmp
read aa &lt; &lt;(find -name prefs.js -exec ls -t {} +)
cp "$aa" /tmp
cd /tmp
MOZ_DISABLE_OOP_PLUGINS=1 "$FIREFOX" -no-remote -profile . $arg_url &amp;
coredump firefox
grep -ao '&lt;video [[:print:]]*&gt;' hulu.core | sort | uniq -w123 &gt; hulu.smil

if ! [ -s hulu.smil ]
then
  warn dumped too soon, retry
  echo $aaa $ccc $ddd
  exit
fi

while read video
do
  serialize_xml video
  if ! [ $arg_cdn ]
  then
    printf '%-9s  %9s\n' $cdn $filetype
  elif [ $cdn$filetype = $arg_cdn$arg_filetype ]
  then
    break
  else
    false
  fi
done &lt; hulu.smil

[ $? = 0 ] || usage
[ $arg_cdn ] || exit
[[ $arg_url =~ [0-9]+ ]]

if [ -a /usr/local/bin/jq ]
then
  download hulu.json "www.hulu.com/api/2.0/video?id=$BASH_REMATCH"
  {
    read uu
    read vv
    read ww
    read xx
  } &lt; &lt;(jq -r '.show.name, .season_number, .episode_number, .title' hulu.json)
  flv="${uu} ${vv}x${ww} ${xx}"
else
  flv="$BASH_REMATCH"
fi

cd "$arg_pwd"
app="${server#*//*/}?${token//amp;}"

log rtmpdump \
  -W http://download.hulu.com/huludesktop.swf \
  -r $server \
  -a $app \
  -y $stream \
  -o "$flv.flv"

if [ -a /usr/local/bin/ffmpeg ]
then
  log ffmpeg -i "$flv.flv" -c copy -v warning "$flv.mp4"
  log rm "$flv.flv"
fi
</pre><div id="menu_item" class="jjMenuItemDiv">Copy without formatting</div><div id="sbi_camera_button" class="sbi_search" style="left: 0px; top: 0px; position: absolute; width: 29px; height: 27px; border: none; margin: 0px; padding: 0px; z-index: 2147483647; display: none;"></div></body></html>
which obviously seems to be messed up as it has HTML in it, but I went ahead and tried it anyway and got:
Image

I then did as I had previously, trying to copy the entire text and then paste it into a "hulu.sh" file, but I get the same error:
Image

Then I thought maybe I should try taking out the html from the downloaded file, giving me:

Code: Select all

#!/bin/bash

if [[ $OSTYPE =~ linux ]]
then
  FIREFOX=firefox
else
  FIREFOX="$PROGRAMFILES/mozilla firefox/firefox"
fi

warn ()
{
  printf '\e[36m%s\e[m\n' "$*"
}

log ()
{
  unset PS4
  set $((set -x; : "$@") 2&gt;&amp;1)
  shift
  warn $*
  eval $*
}

usage ()
{
  echo "usage: $0 [CDN FILETYPE] URL"
  echo
  echo "CDN       content delivery network"
  echo "FILETYPE  quality"
  echo
  echo "run with just URL to get CDN and FILETYPE params"
  exit
}

serialize_xml ()
{
  set "${!1/&lt;}"
  eval set ${1/&gt;}
  for oo
  do
    set ${oo/=/ }
    read ${1/[-:]} &lt;&lt;&lt; $2
  done
}

coredump ()
{
  arg_pid=$!
  arg_prog=$1
  echo waiting for $arg_prog to load...
  aaa=80
  set 0 0
  while sleep 1
  do
    mapfile bbb &lt;/proc/$arg_pid/maps
    (( ccc = ${2} - ${1} ))
    (( ddd = ${#bbb[*]} - ${2} ))
    if (( ${ccc/-} + ${ddd/-} &lt; aaa ))
    then
      break
    fi
    set ${2} ${#bbb[*]}
  done
  echo dumping $arg_prog...
  read WINPID &lt;/proc/$arg_pid/winpid
  dumper hulu $WINPID 2&gt;&amp;- &amp;
  until [ -s hulu.core ]
  do
    sleep 1
  done
  kill -13 $arg_pid
}

download ()
{
  IFS=/ read gg hh &lt;&lt;&lt; "$2"
  exec 3&lt; /dev/tcp/$gg/80
  {
    echo GET /$hh HTTP/1.1
    echo connection: close
    echo host: $gg
    echo
  } &gt;&amp;3
  sed '1,/^$/d' &lt;&amp;3 &gt; $1
}

[ $1 ] || usage
[ $3 ] || set '' '' $1
arg_cdn=$1
arg_filetype=$2
arg_url=$3
arg_pwd=$PWD
cd $WINDIR
echo ProtectedMode=0 &gt; system32/macromed/flash/mms.cfg
rm -r /tmp
mkdir /tmp
cd "$APPDATA/mozilla/firefox"
read aa &lt; &lt;(find -name cookies.sqlite -exec ls -t {} +)
cp "$aa" /tmp
read aa &lt; &lt;(find -name prefs.js -exec ls -t {} +)
cp "$aa" /tmp
cd /tmp
MOZ_DISABLE_OOP_PLUGINS=1 "$FIREFOX" -no-remote -profile . $arg_url &amp;
coredump firefox
grep -ao '&lt;video [[:print:]]*&gt;' hulu.core | sort | uniq -w123 &gt; hulu.smil

if ! [ -s hulu.smil ]
then
  warn dumped too soon, retry
  echo $aaa $ccc $ddd
  exit
fi

while read video
do
  serialize_xml video
  if ! [ $arg_cdn ]
  then
    printf '%-9s  %9s\n' $cdn $filetype
  elif [ $cdn$filetype = $arg_cdn$arg_filetype ]
  then
    break
  else
    false
  fi
done &lt; hulu.smil

[ $? = 0 ] || usage
[ $arg_cdn ] || exit
[[ $arg_url =~ [0-9]+ ]]

if [ -a /usr/local/bin/jq ]
then
  download hulu.json "www.hulu.com/api/2.0/video?id=$BASH_REMATCH"
  {
    read uu
    read vv
    read ww
    read xx
  } &lt; &lt;(jq -r '.show.name, .season_number, .episode_number, .title' hulu.json)
  flv="${uu} ${vv}x${ww} ${xx}"
else
  flv="$BASH_REMATCH"
fi

cd "$arg_pwd"
app="${server#*//*/}?${token//amp;}"

log rtmpdump \
  -W http://download.hulu.com/huludesktop.swf \
  -r $server \
  -a $app \
  -y $stream \
  -o "$flv.flv"

if [ -a /usr/local/bin/ffmpeg ]
then
  log ffmpeg -i "$flv.flv" -c copy -v warning "$flv.mp4"
  log rm "$flv.flv"
fi
But this gives me:
Image

I must be missing something here, I'm not usually this incompetent.

kitana
Posts: 24
Joined: Sat Mar 23, 2013 3:50 am

Re: hulu.sh

Postby kitana » Thu Mar 28, 2013 4:05 pm

Terminator02 wrote:
svnpenn wrote:
Terminator02 wrote:I'm getting this when I try to run the script:
Since I didn't see a download from hulu.sh, I just copied all of it into a new file and named it hulu.sh, here is what's in it:


GitHub has been around for 5 years now, cmon

raw.github.com/svnpenn/a/master/hulu.sh



I must be missing something here, I'm not usually this incompetent.


Not sure if right-clicking the above link>Save link as.. would work or simply pull hulu.sh out of this ZIP

Code: Select all

https://github.com/svnpenn/a/archive/master.zip


Return to “RTMPDump Specific”

Who is online

Users browsing this forum: No registered users and 1 guest