[Script] convert episodes or main-feature from DVD or BD or convert multiple files (on any os)

Discussion of the HandBrake command line interface (CLI)
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Code: Select all

C:\handbrake>ruby.exe hb.rb --input "D:\\" --output "H:\#source#-#title#-#pos#.mkv" --check
hb.rb  Copyright (C) 2013  AlBundy
This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt.
This is free software, and you are welcome to redistribute it under certain conditions.

For questions, feature-requests etc. visit: https://forum.handbrake.fr/viewtopic.php?f=10&t=26163

D:/ (title=, title_alt=, serial=, name=/)
title 01: 00:21:54, 720x576, 25.000 fps, main-feature: true, blocks: 469630, chapters: 1, audio-tracks: eng,fra,ita,deu,spa, subtitles: eng,fra,ita,deu,spa,ell,ces,bul,ron,ita,deu
  audio-tracks:
    1. English (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=eng, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    2. Francais (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=fra, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    3. Italiano (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=ita, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    4. Deutsch (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=deu, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    5. Espanol (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=spa, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
  subtitles:
    1. English (lang=eng, comment=, commentary=false)
    2. Francais (lang=fra, comment=, commentary=false)
    3. Italiano (lang=ita, comment=, commentary=false)
    4. Deutsch (lang=deu, comment=, commentary=false)
    5. Espanol (lang=spa, comment=, commentary=false)
    6. Greek, Modern (lang=ell, comment=, commentary=false)
    7. Czech (lang=ces, comment=, commentary=false)
    8. Bulgarian (lang=bul, comment=, commentary=false)
    9. Romanian (lang=ron, comment=, commentary=false)
    10. Italiano (lang=ita, comment=, commentary=false)
    11. Deutsch (lang=deu, comment=, commentary=false)
  chapters:
    1. 00:21:54 (cells=0->0, blocks=469630)
title 02: 00:21:59, 720x576, 25.000 fps, main-feature: false, blocks: 471012, chapters: 1, audio-tracks: eng,fra,ita,deu,spa, subtitles: eng,fra,ita,deu,spa,ell,ces,bul,ron,ita,deu
  audio-tracks:
    1. English (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=eng, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    2. Francais (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=fra, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    3. Italiano (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=ita, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    4. Deutsch (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=deu, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    5. Espanol (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=spa, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
  subtitles:
    1. English (lang=eng, comment=, commentary=false)
    2. Francais (lang=fra, comment=, commentary=false)
    3. Italiano (lang=ita, comment=, commentary=false)
    4. Deutsch (lang=deu, comment=, commentary=false)
    5. Espanol (lang=spa, comment=, commentary=false)
    6. Greek, Modern (lang=ell, comment=, commentary=false)
    7. Czech (lang=ces, comment=, commentary=false)
    8. Bulgarian (lang=bul, comment=, commentary=false)
    9. Romanian (lang=ron, comment=, commentary=false)
    10. Italiano (lang=ita, comment=, commentary=false)
    11. Deutsch (lang=deu, comment=, commentary=false)
  chapters:
    1. 00:21:59 (cells=0->0, blocks=471012)
title 03: 00:21:59, 720x576, 25.000 fps, main-feature: false, blocks: 470960, chapters: 1, audio-tracks: eng,fra,ita,deu,spa, subtitles: eng,fra,ita,deu,spa,ell,ces,bul,ron,ita,deu
  audio-tracks:
    1. English (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=eng, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    2. Francais (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=fra, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    3. Italiano (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=ita, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    4. Deutsch (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=deu, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
    5. Espanol (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=spa, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
  subtitles:
    1. English (lang=eng, comment=, commentary=false)
    2. Francais (lang=fra, comment=, commentary=false)
    3. Italiano (lang=ita, comment=, commentary=false)
    4. Deutsch (lang=deu, comment=, commentary=false)
    5. Espanol (lang=spa, comment=, commentary=false)
    6. Greek, Modern (lang=ell, comment=, commentary=false)
    7. Czech (lang=ces, comment=, commentary=false)
    8. Bulgarian (lang=bul, comment=, commentary=false)
    9. Romanian (lang=ron, comment=, commentary=false)
    10. Italiano (lang=ita, comment=, commentary=false)
    11. Deutsch (lang=deu, comment=, commentary=false)
  chapters:
    1. 00:21:59 (cells=0->0, blocks=470960)
title 05: 00:00:12, 720x576, 25.000 fps, main-feature: false, blocks: 3304, chapters: 1, audio-tracks: eng, subtitles: eng,fra,ita,deu,spa,ell,ces,bul,ron
  audio-tracks:
    1. English (AC3) (2.0 ch) (codec=AC3, channels=2.0 ch, lang=eng, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
  subtitles:
    1. English (lang=eng, comment=, commentary=false)
    2. Francais (lang=fra, comment=, commentary=false)
    3. Italiano (lang=ita, comment=, commentary=false)
    4. Deutsch (lang=deu, comment=, commentary=false)
    5. Espanol (lang=spa, comment=, commentary=false)
    6. Greek, Modern (lang=ell, comment=, commentary=false)
    7. Czech (lang=ces, comment=, commentary=false)
    8. Bulgarian (lang=bul, comment=, commentary=false)
    9. Romanian (lang=ron, comment=, commentary=false)
  chapters:
    1. 00:00:12 (cells=0->0, blocks=3304)
title 06: 00:03:14, 720x576, 25.000 fps, main-feature: false, blocks: 62327, chapters: 1, audio-tracks: eng, subtitles: eng,fra,ita,deu,spa,ell,ces,bul,ron,ita,deu
  audio-tracks:
    1. English (AC3) (Dolby Surround) (codec=AC3, channels=Dolby Surround, lang=eng, comment=, rate=48000Hz, bitrate=192000bps, commentary=false)
  subtitles:
    1. English (lang=eng, comment=, commentary=false)
    2. Francais (lang=fra, comment=, commentary=false)
    3. Italiano (lang=ita, comment=, commentary=false)
    4. Deutsch (lang=deu, comment=, commentary=false)
    5. Espanol (lang=spa, comment=, commentary=false)
    6. Greek, Modern (lang=ell, comment=, commentary=false)
    7. Czech (lang=ces, comment=, commentary=false)
    8. Bulgarian (lang=bul, comment=, commentary=false)
    9. Romanian (lang=ron, comment=, commentary=false)
    10. Italiano (lang=ita, comment=, commentary=false)
    11. Deutsch (lang=deu, comment=, commentary=false)
  chapters:
    1. 00:03:14 (cells=0->0, blocks=62327)
[2013-09-25, 18:31:59]  WARN -- hb.rb: overview
[2013-09-25, 18:31:59]  WARN -- hb.rb: input: D:/
[2013-09-25, 18:31:59]  WARN -- hb.rb:   no outputs
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

You can try to use d: as input but I think source and title will be empty, unknown or just D.

Source is the name of your sourcefile - since you've used a drive it could be empty.

Title is empty because HandbrakeCLI did not get the label of your disk.

In your command replace #source#_#title# simply with the name of the series and all should work fine.

Al
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

I see what you are saying but I don't understand why GUI can detect source and automatically name the output files using that but CLI can not!

Is this error because source is empty?

Code: Select all

C:\handbrake>ruby.exe hb.rb --input "D:\\" --output "H:\#source#.mkv"
hb.rb  Copyright (C) 2013  AlBundy
This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt.
This is free software, and you are welcome to redistribute it under certain conditions.

For questions, feature-requests etc. visit: https://forum.handbrake.fr/viewtopic.php?f=10&t=26163

[2013-09-25, 20:39:45]  WARN -- hb.rb: D:/ (title=, title_alt=, serial=, name=/)
C:/handbrake/lib/hb_lib.rb:527:in `block in convert': error unsupported extension  (RuntimeError)
        from C:/handbrake/lib/hb_lib.rb:462:in `each'
        from C:/handbrake/lib/hb_lib.rb:462:in `convert'
        from hb.rb:79:in `block (2 levels) in <main>'
        from hb.rb:72:in `each'
        from hb.rb:72:in `block in <main>'
        from hb.rb:60:in `each'
        from hb.rb:60:in `<main>'
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Sorry to bother you! I am trying to rip a series and I wanted the #source# to make the file naming automatic. But since it didn't work I tried to give it a prefix and use #pos#. But I got into two problems:
1) eject does not work and gives me this error after a dvd is ripped correctly:

Code: Select all

C:/handbrake/lib/tools.rb:449:in `popen': No such file or directory - drutil tray eject (Errno::ENOENT)
        from C:/handbrake/lib/tools.rb:449:in `tee'
        from C:/handbrake/lib/hb_lib.rb:793:in `block in convert'
        from C:/handbrake/lib/hb_lib.rb:786:in `each'
        from C:/handbrake/lib/hb_lib.rb:786:in `convert'
        from hb.rb:79:in `block (2 levels) in <main>'
        from hb.rb:72:in `each'
        from hb.rb:72:in `block in <main>'
        from hb.rb:60:in `each'
        from hb.rb:60:in `<main>'
2) then I said ok I eject manually and I reran the command, and it could not create unique name so if previously it ripped Name01.mp4, Name02.mp4, Name03.mp4, now instead of naming the new files Name05.mp4,..., it is reset to Name01.mp4 so it gives me warning that those file exist and quit ripping. Do you know how can fix this?

Thanks,

Arman
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

Hi Arman,

did you use the argument

Code: Select all

--input-done-cmd "drutil tray eject"
?
As mentioned in help-text this is command works only OSX.
For windows there are also some command-line tools to eject a disc - just google for them.
If you don't find a tool I can have a look on my windows machine (I know the tool is called eject.exe).

For you second issue there is no suitable solution because HandbrakeCLI is not able to determine the lable of your disc.
Personally I work like this:

Code: Select all

ruby hb.rb --input D: --episodes --input-done-cmd "eject d:" --output "C:\movies\Series X\Season 01\S1D1_#pos#.m4v"
wait until the disc is done
call the command again and simple change the filename to S1D2_#pos#.m4v

You can also write a simple script that runs forever.

Code: Select all

@ECHO OFF
:LOOP
SET NUM=1
eject.exe -load d:
ruby hb.rb --input D: --episodes --output "C:\movies\Series X\Season 01\S1D%NUM%_#pos#.m4v"
eject.exe d:
PAUSE
SET /A NUM+=1
GOTO :LOOP
It's not tested and works also the the mentioned eject.exe.
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Al,

Thank you for your helpful hints. I couldn't find eject.exe on the internet so I searched and found another way using Visual Basic script for ejecting and closing the CD/DVD tray. Here is the code for eject.vbs

eject.vbs

Code: Select all

MsgBox "Eject!",0,"Disc drive"
Set oWMP = CreateObject("WMPlayer.OCX.7")
Set colCDROMs = oWMP.cdromCollection

For i = 0 To colCDROMs.count-1 
colCDROMs.item(i).eject
Next

MsgBox "Close!",0,"Disc drive"

For i = 0 To colCDROMs.count-1 
colCDROMs.item(i).eject
Next

oWMP.close
and I modified the batch code you gave me a little and found a way to read the dvd title using batch file. So my ripdvd.bat file is

ripdvd.bat

Code: Select all

@ECHO OFF
SET NUM=1
:LOOP
rem : pauses until user press a key. 
rem : it need to be there to make sure when you put dvd inside the dvd is ready before you ask for its title
PAUSE
for /f "tokens=6" %%G IN ('vol d:') do set title=%%G
echo =========================================================
echo    DVD:   %NUM%     Title: %title%
echo =========================================================
ruby.exe hb.rb --input "D:\\" --output "H:\Friends\%title%-#pos#.m4v" --episodes
eject.vbs
SET /A NUM+=1
GOTO :LOOP
I had to put a PAUSE after dvd is inserted to make sure that dvd is ready before I read the title. I put both of these file at the same folder as hb.rb.

Hopefully it helps someone else that is obsessed to make things automatic in Windows.
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

Hi Arman,

thanks for your ideas.
I've bundled eject.exe now with my script (http://thewalter.net/stef/software/eject/).
So input-eject should be available on each platform.

I hopefully also fixed the problem with loading ftools on ruby > 1.8

On widows hb.rb tries now to get the disc label via "vol drive:"

Maybe you can download the current version and check if all is working as expected.

Al
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Al,

when you are reading the title using vol drive:, instead of extracting the drive title the code is extracting drive letter. for example if the result of vol d: is
Volume in drive D is TitleofDrive
Volume Serial Number is 8A34-2299

it takes D as the drive title instead of TitleofDrive.

Arman
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

english windows vs. german windows
german output contains a ":"

Code: Select all

 Datenträger in Laufwerk C: ist System
 Volumeseriennummer: ABCD-DEFG
I've uploaded a new version that should work with your windows too. :-)
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

I've uploaded a new version, that supports user defined presets (it's not tested!).
On windows %APPDATA%\Handbrake\user_presets.xml will be loaded.
OSX and Linux is not possible because the plist-file does not contain the query. :-(

But you can put a preset.xml besides hb.rb where you can define your presets (on all platforms).

All found presets will be shown in help-text.

here is an example:

Code: Select all

<?xml version="1.0"?>
<ArrayOfPreset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<Preset>
	  <Name>iPad and iPhone 4 (SD)</Name>
	  <Query> -f mp4 -w 640 -l 480 -e x264 -b 2048 -a 1 -E faac -6 stereo -R 48 -B 160 -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1</Query>
	</Preset>

	<Preset>
	  <Name>iPad and iPhone 4 (iFrame)</Name>
	  <Query> -f mp4 -w 960 -l 540 -e x264 -b 4096 -a 1 -E faac -6 stereo -R 48 -B 160 -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1</Query>
	</Preset>
	
	<Preset>
	  <Name>iPad and iPhone 4 (720p)</Name>
	  <Query> -f mp4 -w 1280 -l 720 -e x264 -b 5120 -a 1 -E faac -6 stereo -R 48 -B 160 -D 0.0 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1</Query>
	</Preset>

</ArrayOfPreset>
Audio-Settings will be used for each selected audio-track, so you can use a preset together with the lang-options.
User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by s55 »

@AIBundy - The CLI query was removed from the Windows Preset files some time ago. It's no longer there. The internal architecture is all model driven now.
User presets don't get upgraded between versions, so it's possible you may still have some legacy presets there that don't work anymore.

For example:

Code: Select all

<?xml version="1.0"?>
<ArrayOfPreset xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Preset>
    <Category>User Presets</Category>
    <IsBuildIn>false</IsBuildIn>
    <IsDefault>false</IsDefault>
    <Name>Test</Name>
    <PictureSettingsMode>Custom</PictureSettingsMode>
    <UseDeinterlace>false</UseDeinterlace>
    <Task>
      <Title>0</Title>
      <Angle>0</Angle>
      <PointToPointMode>Chapters</PointToPointMode>
      <StartPoint>0</StartPoint>
      <EndPoint>0</EndPoint>
      <OutputFormat>Mp4</OutputFormat>
      <OptimizeMP4>false</OptimizeMP4>
      <IPod5GSupport>false</IPod5GSupport>
      <Width xsi:nil="true" />
      <Height xsi:nil="true" />
      <MaxWidth>0</MaxWidth>
      <MaxHeight>0</MaxHeight>
      <Cropping>
        <Top>0</Top>
        <Bottom>0</Bottom>
        <Left>0</Left>
        <Right>0</Right>
      </Cropping>
      <HasCropping>false</HasCropping>
      <Anamorphic>Loose</Anamorphic>
      <DisplayWidth xsi:nil="true" />
      <KeepDisplayAspect>false</KeepDisplayAspect>
      <PixelAspectX>0</PixelAspectX>
      <PixelAspectY>0</PixelAspectY>
      <Modulus>2</Modulus>
      <Deinterlace>Off</Deinterlace>
      <Decomb>Default</Decomb>
      <Detelecine>Off</Detelecine>
      <Denoise>Off</Denoise>
      <Deblock>4</Deblock>
      <Grayscale>false</Grayscale>
      <VideoEncodeRateType>ConstantQuality</VideoEncodeRateType>
      <VideoEncoder>X264</VideoEncoder>
      <FramerateMode>VFR</FramerateMode>
      <Quality>20</Quality>
      <VideoBitrate xsi:nil="true" />
      <TwoPass>false</TwoPass>
      <TurboFirstPass>false</TurboFirstPass>
      <Framerate xsi:nil="true" />
      <AudioTracks />
      <AllowedPassthruOptions>
        <AudioAllowAACPass>true</AudioAllowAACPass>
        <AudioAllowAC3Pass>true</AudioAllowAC3Pass>
        <AudioAllowDTSHDPass>true</AudioAllowDTSHDPass>
        <AudioAllowDTSPass>true</AudioAllowDTSPass>
        <AudioAllowMP3Pass>true</AudioAllowMP3Pass>
        <AudioEncoderFallback>Ac3</AudioEncoderFallback>
      </AllowedPassthruOptions>
      <SubtitleTracks />
      <IncludeChapterMarkers>true</IncludeChapterMarkers>
      <ChapterNames />
      <X264Preset>Medium</X264Preset>
      <QsvPreset>Quality</QsvPreset>
      <H264Profile>High</H264Profile>
      <H264Level>4.1</H264Level>
      <X264Tune>None</X264Tune>
      <FastDecode>false</FastDecode>
      <PreviewStartAt xsi:nil="true" />
      <PreviewDuration xsi:nil="true" />
      <IsPreviewEncode>false</IsPreviewEncode>
      <PreviewEncodeDuration>0</PreviewEncodeDuration>
      <ShowAdvancedTab>false</ShowAdvancedTab>
    </Task>
    <UsePictureFilters>true</UsePictureFilters>
  </Preset>
</ArrayOfPreset>
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

What a pity. :-(
Is there any way to get the query in a script without reimplementing the internal logic of handbrake?

Al
User avatar
s55
HandBrake Team
Posts: 10350
Joined: Sun Dec 24, 2006 1:05 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by s55 »

The best way to handle this, is to ask users to export the plist via the gui (the windows gui exports plist format although it doesn't use it internally)
You may be able to use https://trac.handbrake.fr/browser/trunk ... anicure.rb to help if your using ruby
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

This looks good - I removed the preset-handling from last version and loading now all plist-files in the directory of hb.rb.
So after exporting one or more presets in GUI they can be loaded by hb.rb.
--> It's not really tested but I think it should work (new version is already uploaded).

ATTENTION: new version needs the gem "plist" - users need to install it via

Code: Select all

gem install plist
Al

@s55 or Rodeo: Maybe someone can make the following change to manicure.rb to avoid an exit if the file is included in my script. :-)

Code: Select all

if __FILE__ == $0
  # First grab the specified CLI options
  options = readOptions
  
  # Only run if one of the useful CLI flags have been passed
  if options.cliraw == true || options.cliparse == true || options.api == true || options.apilist == true
    # This line is the ignition -- generates hashes of
    # presets and then displays them to the screen
    # with the options the user selects on the CLI. 
    Display.new( Presets.new.hashMasterList, options )
  else
    # Direct the user to the help
    puts "\n\tUsage: manicure.rb [options]"
    puts "\tSee help with -h or --help"
  end
end
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

I've uploaded a new version again.
plist is now optional - but when it's not installed, presets can not be used of course.

Just a hint: Presets with same name will override builtin-presets.
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Al,

Do you know what this error means?

Code: Select all

c:\handbrake>tag_episode.rb --id Friends --season 1 --episode 1 --tag --rename h:\Friends\01\FRIENDS*.mkv
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': C:/handbrake/lib/provider_lib.rb:55: invalid multibyte char (US-ASCII) (SyntaxError)
C:/handbrake/lib/provider_lib.rb:55: invalid multibyte char (US-ASCII)
C:/handbrake/lib/provider_lib.rb:55: syntax error, unexpected $end, expecting ')'
    content.gsub!(/&Ouml;/, "A-")
                               ^
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/handbrake/tag_episode.rb:5:in `<main>'

c:\handbrake>tag_episode.rb --provider imdb --id Friends --season 1 --episode 1 --tag --rename h:\Friends\01\FRIENDS*.mkv
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': C:/handbrake/lib/provider_lib.rb:55: invalid multibyte char (US-ASCII) (SyntaxError)
C:/handbrake/lib/provider_lib.rb:55: invalid multibyte char (US-ASCII)
C:/handbrake/lib/provider_lib.rb:55: syntax error, unexpected $end, expecting ')'
    content.gsub!(/&Ouml;/, "A-")
                               ^
        from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from C:/handbrake/tag_episode.rb:5:in `<main>'
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

Seems to be an encoding issue.

Please open tag_episode. rb in a text-editor and add the following text after the first line

Code: Select all

# encoding: UTF-8 


If this works I'll add this to my scripts too.

Al
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Thank you Al, but it didn't work. It gives the same error :(
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

Next try : add the mentioned line at top of lib/provider_lib.rb
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

It helped with the previous problem but now it get another error:

Code: Select all

c:\handbrake>tag_episode.rb --id friends --season 1 --episode 1 --tag --rename h:\Friends\01\FRIENDS*.mkv
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
C:/handbrake/tag_episode.rb:61:in `<main>': invalid option: --id (OptionParser::InvalidOption)
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

Sounds good - I think I've changed the argument from --Id to --query.
just run --help to get a list of all options.

Al
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

I've uploaded a new version with the utf-8 fix and with better readable error-message for wrong argument in tag_episode.rb.

I've also updated the help-text for tag_episode.rb in the first post.

Al
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Thank you now it works. One question though: is it possible to filter characters that are not permitted in a file name? I am asking because I am renaming my files and when it encounters a character that is not permitted it just exit the script with an error. I mean these characters: /\?%*:|"<>
AlBundy
Bright Spark User
Posts: 377
Joined: Mon Dec 31, 2012 4:47 am

Re: [Script] rip all episodes or only main-feature from DVD

Post by AlBundy »

I've uploaded a new version that will replace the mentioned special-characters with a "_".

Al
arman
Posts: 13
Joined: Wed Sep 25, 2013 2:20 pm

Re: [Script] rip all episodes or only main-feature from DVD

Post by arman »

Thank you but it gives this error:

Code: Select all

c:\handbrake>tag_episode.rb --provider imdb --query friends --season 1 --episode 16 --rename --name "friends" --pattern  "#name# - #season#x#episode# - #title#" h:\Friends\01\1\FRIENDS*.mkv
C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': iconv will be deprecated in the future, use String#encode instead.
tag_episode.rb Copyright (C) 2013 AlBundy
  This program comes with ABSOLUTELY NO WARRANTY; for details see LICENSE.txt.
  This is free software, and you are welcome to redistribute it under certain conditions.

  For questions, feature-requests etc. visit: https://forum.handbrake.fr/viewtopic.php?f=10&t=26163


C:/handbrake/tag_episode.rb:112:in `gsub!': can't convert nil into String (TypeError)
        from C:/handbrake/tag_episode.rb:112:in `block (2 levels) in <main>'
        from C:/handbrake/tag_episode.rb:111:in `each'
        from C:/handbrake/tag_episode.rb:111:in `block in <main>'
        from C:/handbrake/tag_episode.rb:90:in `each'
        from C:/handbrake/tag_episode.rb:90:in `<main>'
Post Reply