python and ruby folk in here

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    python and ruby folk in here

    im putting together a collection of youtube one liners.

    anyone wanna submit one that works from console to get a youtube video id out of a youtube url?

    ;)

    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • extreme
    Confirmed User
    • Oct 2002
    • 2120

    #2
    do you mean "uAFjgpuWREM" from http://www.youtube.com/watch?v=uAFjg...6cFAAAAAAAAAAA or what?

    Comment

    • fris
      Too lazy to set a custom title
      • Aug 2002
      • 55679

      #3
      ya exactly

      perl

      Code:
      perl -e '$_=shift; print(/v=(.+)/);' http://www.youtube.com/watch?v=8tRUckf0WbY
      awk

      Code:
      echo http://www.youtube.com/watch?v=4bQOSRm9YiQ | awk -F 'v=' '{print $2}'
      sed

      Code:
      echo http://www.youtube.com/watch?v=sGgOM1UsqtE | sed 's/.*watch?v=\([^&]*\).*/\1/'
      echo http://www.youtube.com/watch?v=sGgOM1UsqtE | grep -o 'watch\?v=[^&"]+' | sed -e 's#^[^=]*=##'
      echo http://www.youtube.com/watch?v=sGgOM1UsqtE | sed -ne 's#^.*watch?v=\([^&"]*\+\).*$#\1#p'
      echo http://www.youtube.com/watch?v=sGgOM1UsqtE | sed '/watch?v=/! d;s/.*v=//;s/\(.\{11\}\).*/\1/'
      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

      Comment

      • Brujah
        Beer Money Baron
        • Jan 2001
        • 22157

        #4
        No php?

        Code:
        php -r 'echo next(explode( "v=", $argv[1] ) );' http://www.youtube.com/watch?v=8tRUckf0WbY
        or

        Code:
        php -r 'echo preg_replace ( "/.*v\=([a-z0-9]+).*/i", "$1", $argv[1] );' http://www.youtube.com/watch?v=8tRUckf0WbY

        Comment

        • Brujah
          Beer Money Baron
          • Jan 2001
          • 22157

          #5
          here's a ruby sample:

          Code:
          echo 'http://www.youtube.com/watch?v=8tRUckf0WbY' | ruby -ne 'puts $1 if /v=(\w+)/'

          Comment

          • fris
            Too lazy to set a custom title
            • Aug 2002
            • 55679

            #6
            thanks just need a python one now ;)
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

            Comment

            • Brujah
              Beer Money Baron
              • Jan 2001
              • 22157

              #7
              I don't normally use python, but since no one else is bothering...

              Code:
              python -c "import re,sys; m = re.split('v=',sys.argv[1]); print m[1];" http://www.youtube.com/watch?v=8tRUckf0WbY

              Comment

              • fris
                Too lazy to set a custom title
                • Aug 2002
                • 55679

                #8
                spanks ;)
                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                Comment

                • fris
                  Too lazy to set a custom title
                  • Aug 2002
                  • 55679

                  #9
                  here is some bash ;)

                  Code:
                  echo http://www.youtube.com/watch?v=sGgOM1UsqtE | grep -E 'v=[A-Za-z0-9_-]' | cut -d "=" -f 2
                  Code:
                  var='http://www.youtube.com/watch?v=sGgOM1UsqtE'; echo "${var#*v=}"
                  Code:
                  var='http://www.youtube.com/watch?v=sGgOM1UsqtE'; echo "${var##*[?&]v=}"
                  ;)
                  Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                  Comment

                  • fris
                    Too lazy to set a custom title
                    • Aug 2002
                    • 55679

                    #10
                    zsh ;)

                    Code:
                    s='http://www.youtube.com/watch?v=k6R9hMV1jNk'; a=("${(s/v=/)s}"); echo $a[2]
                    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                    Comment

                    • Emil
                      Confirmed User
                      • Feb 2007
                      • 5658

                      #11
                      Qbasic???
                      Free 🅑🅘🅣🅒🅞🅘🅝🅢 Every Hour (Yes, really. Free ₿itCoins.)
                      (Signup with ONLY your Email and Password. You can also refer people and get even more.)

                      Comment

                      • Brujah
                        Beer Money Baron
                        • Jan 2001
                        • 22157

                        #12
                        here is some human
                        http://www.youtube.com/watch?v=k6R9hMV1jNk

                        Code:
                        k6R9hMV1jNk

                        Comment

                        • fris
                          Too lazy to set a custom title
                          • Aug 2002
                          • 55679

                          #13
                          Originally posted by Brujah
                          here is some human
                          http://www.youtube.com/watch?v=k6R9hMV1jNk

                          Code:
                          k6R9hMV1jNk
                          human heh ;)
                          Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                          Comment

                          Working...